Open
Description
By extending the signature of useAppState
we can scope the tracking of state.
const Item = ({ id }) => {
const item = useAppState(state => state.items[id]) // Tracks ["items.$id"] and any other accessed state on item
}
This is different than doing:
const Item = ({ id }) => {
const item = useAppState().items[id] // Tracks ["items", "items.$id"] and any other accessed state on item
}
The second example here also tracks the "items" themselves, meaning any added/removed items will cause this component to reconcile. We can currently solve this by passing the whole item down to the component, and do useAppState
without using any actual state... this new solution seems more intuitive.
Metadata
Metadata
Assignees
Labels
No labels