You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
I'm creating a demo of stability of Microstates trees. My goal was to show that Microstates re-uses references between transitions allowing caching of trees of children based on reference to a microstate.
functionFamilyTree({ person }){letname=useMemo(()=>{console.log('Updating name to',person.name.state);return(<inputvalue={person.name.state}onChange={e=>person.name.set(e.target.value)}/>);},[person.name]);letfather=useMemo(()=><FamilyTreeperson={person.father}/>,[person.father]);letmother=useMemo(()=><FamilyTreeperson={person.mother}/>,[person.mother]);return(<>{name}{person.name.state&&(<ul><li>Father: {father}</li><li>Mother: {mother}</li></ul>)}</>);}
In this example, I'm memoizing children based on references to microstates in person microstate. I added a console log to log when an input is being re-rendered. Here is a screen recording of this in action.
Open React Devtools and activate "Highlight Updates"
Enter names a few level deep
I would expect to only see the input that I'm highlighting update, but it's showing that parent's input fields are updating as well. The console log shows that only one input is being updated when an input is changed. I suspect that it's highlighting parent elements where children are changing, but I wouldn't expect this to be visible.