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
In a scenario where a function that is listening on a facet is calling another function created with useFacetCallback, the value of the same facet inside the second callback might be outdated.
For example:
constfacet=createFacet({initialValue: 'old value'})functionComp(){// Since this is run on useLayoutEffect, it will// add the constcallback=useFacetCallback((value)=>value,[],[facet])// Since this is run on render, it will add the// `.observe` subscription firstuseMemo(()=>{facet.observe((value)=>{console.log('here be new value: ',value)console.log('...and here is still old value: ',callback())})})returnnull}facet.set('new value')
The text was updated successfully, but these errors were encountered:
The fix should probably be that useFacetCallback reads the facet values instead of listening to changes in them. It's unclear why we went with the first one.
In a scenario where a function that is listening on a facet is calling another function created with
useFacetCallback
, the value of the same facet inside the second callback might be outdated.For example:
The text was updated successfully, but these errors were encountered: