I am trying out unstated
(https://github.com/jamiebuilds/unstated) and like its simplicity but am experiencing unexpected behavior. At the top level I have:
<Provider>
<Subscribe to={[MyDataContainer]}>
{myDataStore => (
<TopLevelComponent dataStore={myDataStore} />
)}
</Subscribe>
</Provider>
Then way down my component tree, I access the store again using something like this:
<Subscribe to={[MyDataContainer]}>
{myDataStore => (
<Leaf dataStore={myDataStore} />
)}
</Subscribe>
This works great as long as my tree stays the same. As soon as I have a state change that requires rebuilding the leaves, the state object in my data container gets re-initialized and wiped out. What am I doing wrong?