Sometimes, we only need to use the accessor/mutator of a shared state (e.g: setBlockPickerMenu
).
const [blockPickerMenu, setBlockPickerMenu] = useRecoilState(blockPickerMenuState);
...
setBlockPickerMenu(null)
And we don't need the value itself (e.g: blockPickerMenu
).
What happens inside React when we're doing the above? Does the component subscribes to changes to blockPickerMenu
even though we don't actively use it? Does it perform needless re-renders upon changes? Is there a way to optimize things somehow?
The above example uses Recoil, but I assumed it'd work similarly for any shared state (Redux, etc.)