React Native LayoutAnimation allows automatically animating views to new positions when the next layout occurs.
I have items stored in Redux which are passed as properties into a component that renders them. When the properties change I want the component contents to animate accordingly. However, I'm unsure where in the component to call LayoutAnimation.configureNext()
.
The componentWillUpdate
method would seem to be the correct place as it is called before rendering, but the method is deprecated and going to be removed. componentDidUpdate
is too late, as the render/layout has already taken place.
I got it working by copying the properties into the component state and calling LayoutAnimation.configureNext()
in componentDidUpdate
, which forces a second re-render using the animations. This may have the added benefit of somewhat isolating the update of this component from the previous render cycle which may have other component updates, but it seems cumbersome.
Where in the lifecycle methods should LayoutAnimation.configureNext()
be called?