Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use with SectionList #245

Open
sergey-king opened this issue Oct 14, 2021 · 3 comments
Open

Unable to use with SectionList #245

sergey-king opened this issue Oct 14, 2021 · 3 comments

Comments

@sergey-king
Copy link

When used with react-native SectionList and called with ref to enable scrolling like:
props.start(false, refSectionList.current); - getting a TypeError as below;

TypeError: scrollView.scrollTo is not a function. (In 'scrollView.scrollTo({ y: yOffsett, animated: false })', 'scrollView.scrollTo' is undefined) at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0

React-Native SectionList Inherits ScrollView Props since it's a wrapper around , and thus inherits its props (as well as those of ), so I believe this should work? @mohebifar

@sergey-king
Copy link
Author

Looks like '.scrollTo()' method is not available on SectionList. Is there a way to add SectionList scrollToLocation() method support. Thanks!

@jakequade
Copy link
Contributor

@sergey-king for what it's worth, you can use the getScrollResponder() method on a sectionlist ref as the scrollview ref for the tour. It's not ideal, but it works and exposes the methods you need.

const Thing = ({ start }: CopilotWrappedComponentProps) => {
  const scrollRef = useRef<ScrollView | undefined>().current;

  useEffect(() => {
    if (start && scrollRef) {
      start(false, scrollRef);
    }
  }, [])

  return <SectionList
    ref={(ref) => {
      scrollRef = ref?.getScrollResponder();
    }}
    // ...
  />
}

@sergey-king
Copy link
Author

sergey-king commented Mar 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants