2

It was once recommended to use componentWillReact() to trigger layout animations in response to changes in observable values, like so:

componentWillReact() {
        LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
    }

However, componentWillReact() has been removed in mobx-react@6.

What is the recommended replacement? My observable class should know nothing about it's observer, so I'm looking for a similar event-driven solution.

Thanks!

HolySamosa
  • 9,011
  • 14
  • 69
  • 102

1 Answers1

1

If I got your question correctly, and you have a chance to use functional component, try the useLayoutEffect hook instead of componentWillReact, declare observable value as its deps, and call LayoutAnimation.configureNext in hook's callback, like this:

useLayoutEffect(() => {
  LayoutAnimation.easeInEaseOut();
}, [store.something]);
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77