Answer the question
In order to leave comments, you need to log in
How to trigger an event in React when a component is fully or partially displayed on the user's screen?
Hello, I have a list of notifications in the form of a tile, and I need to mark notifications as read when they are completely or 85 percent displayed on the user's screen.
How can this be implemented?
Answer the question
In order to leave comments, you need to log in
You can change the state as soon as the component is mounted on the page. For example, as soon as the user calls the component with the notification tile, change the state: setIsChecked(true).
Create your own stateful hook and use useEffect to subscribe to changes to props or other dependencies . Then call this hook in the notification tile component and work with the state.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question