Should detect whole state spreading
See original GitHub issueWith 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 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
- 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.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:22 (12 by maintainers)
Top Results From Across the Web
CDC Confirms Person-to-Person Spread of New Coronavirus ...
Recognizing early on that the 2019-nCoV could potentially spread between people, CDC has been working closely with state and local partners ...
Read more >PSMA PET-CT Accurately Detects Prostate Cancer Spread - NCI
Under the approval, the tracer can be used in PET imaging for prostate cancer that is suspected of having spread to other parts...
Read more >FACT SHEET: Biden-Harris Administration's Monkeypox ...
The virus, however, is spreading in the United States and globally, and requires a comprehensive response from federal, state, local, ...
Read more >Home - Illinois.gov
Getting tested for COVID-19 and quarantining if you're positive is a proven method of slowing the spread. If you think you've been exposed...
Read more >Transmission of SARS-CoV-2: implications for infection ...
Viable SARS-CoV-2 virus and/or RNA detected by RT-PCR can be found on ... Knowing when an infected person can spread SARS-CoV-2 is just...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There are 2 polyfills, one is simple - could set a trap on set/get/call. Could be done via object.defineProperty. Second is much more complex, and also patches Object methods, to work with “fake” polyfill.
Unfortunately, I’ve failed to solve this task. (for now, looking other ways)
babel-plugin-transform-object-rest-spread destroys the proxy. It just gets all the props outsite “the state”, and stores in another object, already not controlled by me. I could count or “all” methods as used, or all as not used. But I also could trigger on “enumeration”/spreading.
As long there is no way to distinguish object spread and deep-equal - that’s really no way to solve this. Solution made:
ownKeys
injecting the “enumeration trap” then someone going to enumerate object. Not affecting “normal” objects, and production. In case of access to that object proxyequal will inform about enumeration, and memoize-state provide a link to a function.Solution tried:
{[Symbol.toPrimitive]:....}
, deferring key access recording. But, if no one will cast “result” to primitive type - it will not work. And nobody will.state.values ? state.oneKey : state:anotherKey
ordeep/shallow-compare
.Followup - let user disable this notification, or enable only for top-level keys.