MobX-State-Tree and Fast Refresh

Jesse Cooper
Feb 9, 2021

--

MobX-State-Tree logo + React logo

It’s hard to imagine going back to the old ways once you try Fast Refresh. MobX-State-Tree just needs a little help to work with it properly. Here’s a simple hook that preserves your app’s state whenever you modify store code or dependencies:

Disclaimer: State is not preserved when you make changes that are incompatible with the previous snapshot, such as changing the type of a model property. This occurs pretty rarely in practice, however.

This little snippet has given the Iterate team a big productivity boost. Fast Refresh now works faithfully for our most common development tasks. I hope this proves useful for you as well.

--

--