With a given code
const mapState = ({ page, direction, ...state }) => ({
page,
direction,
isLoading: isLoading(state)
})
memoize state should not react to any state change, as it would.
Posible solutions:
-
Currently, memoize react on key get, but it could react on key read. This will require all objects to be wrapped by something with valueOf/toString. They key will be added to tracking if someone "read" it, or "return" it.
Could affect performance. Unstable.
-
Track such situations and encourage a user to change the code
- cast function to string, and search for spread operator (unstable)
- detect then all keys of state used, and inform user of a potential problem. Easy to do, could be enabled by default in dev mode.
With a given code
memoize state should not react to any state change, as it would.
Posible solutions:
Currently, memoize react on key
get, but it could react on keyread. This will require all objects to be wrapped by something with valueOf/toString. They key will be added to tracking if someone "read" it, or "return" it.Could affect performance. Unstable.
Track such situations and encourage a user to change the code