Skip to content

I thought react-spring (useSpring) causes the component to re-render, but it may not? #1436

Discussion options

You must be logged in to vote

The API allows spring to animate outside of the react-render loop. In the first example you shared, you're using state to dictate the props of the spring. In the third example you've shared you've got your spring defined and ready so the animated component does not need to have a re-render to have it's styles updated.

You could also look at using the Imperative API we now have which would allow you to change the state of the spring in reaction to events without updating the state of the component. So that's the kind of how and why but in summary:

HOW – the animated component
WHY – it's better and more performance efficient to be honest.

How to prevent it? IMO use the imperative api, i lin…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@nonopolarity
Comment options

@joshuaellis
Comment options

@nonopolarity
Comment options

@joshuaellis
Comment options

@nonopolarity
Comment options

Answer selected by joshuaellis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1435 on April 21, 2021 07:18.