Does not work with Object.values/Object.keys
See original GitHub issueimport memoizeState from "memoize-state";
const selector = memoizeState(s => {
return Object.values(s.items).map(x => x.text);
});
const state = {
items: {
1: { text: "foo" }
}
};
console.log(selector(state));
// expected ['foo']
// actual ['foo'] ✅
const newState = {
...state,
items: {
...state.items,
2: { text: "bar" }
}
};
console.log(selector(newState));
// expected ['foo', 'bar']
// actual ['foo'] 🚩
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Object.keys, values, entries - The Modern JavaScript Tutorial
Object.keys(obj) – returns an array of keys. Object.values(obj) – returns an array of values. Object.entries( ...
Read more >How to Access Object's Keys, Values, and Entries in JavaScript
Let's see what utility functions provide JavaScript to extract the keys, values, and entries from an object. 1. Object.keys() returns keys.
Read more >Object.keys() - JavaScript - MDN Web Docs
Non-object arguments are coerced to objects. Only strings may have own enumerable properties, while all other primitives return an empty array.
Read more >Javascript: Object have keys, but Object.keys returns empty
i got containers and courses from remote server. everything was working perfectly. now i'm trying to load data from local database. it's not...
Read more >Improve Object.keys(object) and Object.values(object) #26901
Search Terms Suggestion When all keys and values of object is known Object.keys(object) should return array type of union of known ...
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
The fix was added into the underlying
proxyequal
, but not yet released.That’s actually a good issue. You are assessing deeply nested
text
property, and algorithm thinks that it’s what you are interested in - notitem
, but onlyitem.text
. By the same long - notitems
butitem
. Result is clear - new stuff is ignored.It’s working for arrays, as long
length
property changes, but not for objects. The funny moment - it’s impossible to solve this problem with the current algorithm.Idea - for every enumeration operation(ownKeys proxy hook) “asses” a secret property = concatenated keys, but this is not a quite ES5 polyfill compatible. I really don’t want to use old spread_guard logic.
@dai-shi - might be you have some bright ideas?