react-scroll-sync | Synced scroll position | Frontend Framework library
kandi X-RAY | react-scroll-sync Summary
kandi X-RAY | react-scroll-sync Summary
Synced scroll position across multiple scrollable elements
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-scroll-sync
react-scroll-sync Key Features
react-scroll-sync Examples and Code Snippets
Community Discussions
Trending Discussions on react-scroll-sync
QUESTION
I'm trying to control the scroll position of a textarea using a React component's state, but it doesn't move when I call setState()
.
Here's an example where clicking on the link should scroll to the top of the textarea, but it doesn't move. Scrolling with the scroll bar can log the positions, and the field moves. Clicking on the link writes a message to the console, but the scroll position doesn't move. I based this approach on the controlled components described in the ReactJS documentation.
...ANSWER
Answered 2019-Mar-27 at 04:47Tommy May explained in a comment that scrollTop
isn't an HTML attribute, so I can't link it directly to the component state or properties. However, I found that the componentDidUpdate()
method can be used to handle changes to the state or properties.
Here's an updated example that uses componentDidUpdate()
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-scroll-sync
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page