I noticed this too - you can use React.useMemo to create a memoized value object. That way the object is only updated when one of its dependencies updates and then avoid rerendering all consumer component trees so many times.
React.useMemo
value
const [status, setStatus] = useState('paused'); const togglePlayPause = () => setStatus(status === 'playing' ? 'paused' : 'playing'); const contextValue = useMemo(() => ({ status, togglePlayPause }), [status, togglePlayPause])
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I noticed this too - you can use
React.useMemo
to create a memoizedvalue
object. That way the object is only updated when one of its dependencies updates and then avoid rerendering all consumer component trees so many times.