question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DraxScrollView scrollTo function is undefined.

See original GitHub issue

I am trying to make the card center of the DraxScrollView which will have the dynamic width based upon the number of the cards DraxScrollView is acquiring.

I have used <DraxScrollView contentContainerStyle={[styles.receivedZone,]} alwaysBounceVertical={true} maximumZoomScale={10} minimumZoomScale={-2} directionalLockEnabled={false} horizontal={true} ref={(ref) => this.draxScrollViewRef = ref.getNodes()} > <View onLayout={event => this.layout = event.nativeEvent.layout} style={{ position: 'relative', width: 105, height: 105, overflow: 'visible' }} > <Text>Cards content</Text> </View> </DraxScrollView>

The reference is then used on ` componentDidMount = async () => {

	setTimeout(() => {
		this.draxScrollViewRef.getNodes().scrollTo({
			y: this.layout.y,
			x: this.layout.x - GlobalItem.deviceWidth / 2 + 55,
			animated: false
		})
	}, 100);

}`

But the end result is TypeError: _this.draxScrollViewRef.getNodes is not a function. (In '_this.draxScrollViewRef.getNodes()', '_this.draxScrollViewRef.getNodes' is undefined)

What can be done?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
dipeshkarmacharyaacommented, Aug 7, 2020

I have found the solution to access ScrollView ref by exporting onScrollRefNew on line number 30.

Previous Code // Set the ScrollView and node handle refs.

const setScrollViewRefs = react_1.useCallback((ref) => {
     scrollRef.current = ref;
     nodeHandleRef.current = ref && react_native_1.findNodeHandle(ref);
 }, []);

New Code // Set the ScrollView and node handle refs.

    const setScrollViewRefs = react_1.useCallback((ref) => {
        scrollRef.current = ref;
        nodeHandleRef.current = ref && react_native_1.findNodeHandle(ref);
        return onScrollRefNew?.(ref);
    }, [onScrollRefNew]);
4reactions
lafioscacommented, Aug 3, 2020

I believe the current implementation of DraxScrollView does not provide a way to access the internal ScrollView ref. I think it needs to be enhanced to support the functionality you’re requesting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native ScrollView scrollTo function is not working
Code snippet of how I created ref for the scrollView: class SearchResult extends React.Component { constructor(props) { super ...
Read more >
Element.scrollTop - Web APIs | MDN
The Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically.
Read more >
Javascript Window scrollTo() Method - GeeksforGeeks
The Window scrollTo() method is used to scroll to a particular set of coordinates in the document. Syntax: window.scrollTo(x-coord, y-coord).
Read more >
scrollTo | React Native Reanimated - Software Mansion
Provides synchronous scroll on the UI thread to a given offset using an animated ref to a scroll view. This allows performing smooth...
Read more >
HTML DOM Element scrollIntoView() Method - W3Schools
Definition and Usage. The scrollIntoView() method scrolls an element into the visible area of the browser window. ... function scrollToBottom() { element.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found