react-native-modalize
react-native-modalize copied to clipboard
Unable to scrollToIndex
Unable to use the ref to scrollToIndex({ index: 0 ... within the modal
Goal is to reset the scroll position to the top when the modal is "alwaysOpen" closed.
Reproduce
const mapRef = useRef(null);
...
<Modalize
ref={modalRef}
modalHeight={height - 80}
alwaysOpen={100}
disableScrollIfPossible={true}
onPositionChange={(pos) => {
if(pos !== 'top') {
modalRef?.current?.scrollToIndex({ index: 0, animated: true });
}
}}
threshold={40}
> ... </Modalize>
Error: scrollToIndex is not a function.
Dependencies:
- react-native-modalize [e.g. 1.3.7-rc.19]
- react-native [e.g. 0.62.0]
- react-native-gesture-handler [e.g. 1.6.0]
- expo/react-navigation/react-native-navigation: [e.g. [email protected]]
suggestion in #125 doesn't seem to work
i guess the refs are different between the scrollview/flatlist and the bottomsheet itself. You may try to use contentRef
like documented here
i guess the refs are different between the scrollview/flatlist and the bottomsheet itself. You may try to use
contentRef
like documented here
I'm using contentRef with SectionList, but contentRef always undefined. I can not use SectionList methods.
I was able to get it to work by using a contentRef
` <Modalize contentRef={contentRef} ....
contentRef?.current?.scrollTo({ x: 0, y: 0, animated: true }); `