Closed dai-shi closed 5 years ago
Yeah. It should be this way, and should not.
state = { a, b }
// it should maintain ref equality
newState.a === oldState.b
So a
would be the same Proxy
for both instances. That should be that way.
And it would have callbacks, defined for the first use, not the second. That should not be that way.
It's a bit complicated, but one have to return the same objects, with a different setup. And I am not sure it is possible.
To be more concrete - for this case it is possible - push "path" on component access, and pop it just after. So.any.deep.property access would work.
Once you store variable somewhere const {a:oldA}=oldState; const {a: newA } = newState
- information is lost.
Probably:
Look like .2
would fix the current buggy behaviour, then you lose the track, and .1
would make tracking more accurate.
PS: Thank you for an issue.
Complicated... but I understand the object identity.
Let me try caching trapped
in the front.
Thanks!
Here's what I did: https://github.com/dai-shi/react-hooks-easy-redux/commit/23e2c5ab75fed0f36787358ea52af12bb48f1697
The benchmark result seems good: https://github.com/dai-shi/react-hooks-easy-redux/issues/3#issuecomment-466833745
Hi, I'm trying to improve https://github.com/dai-shi/react-hooks-easy-redux with proxyMap, but it doesn't behave as I expect. Do I misunderstand the usage?
I was expecting
trapped2.affected
to be['.b']
andtrapped1.affected
to be kept['.a']
.