New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access array methods on property #66
Comments
Hi @ericktucto! The hybrids cache mechanism foundation is an equality check between property values over time. It means that you cannot safely modify object instances, because then other properties will not be notified about the change. To protect library users, for example In the get definition of the property in documentation you can read:
All methods that you mentioned - host.todos = [...host.todos, newTodo]; |
Here you have a few hints about your code example: host.maxId++; You can avoid manually updated property - it is strictly related to current const ListTodos = {
maxId: ({ todos }) => todos[todos.length - 1].id, // if your ids will increment (so the last is the highest)
// or
maxId: ({ todos }) => todos.length, // if you relay on the count of todos
} Then in your function addTodo(host) {
const newTodo = { text: host.text, id: host.maxId + 1 };
host.todos = [...host.todos, newTodo];
} Going even further your |
Feel free to re-open, if you will have other problems with the subject. |
Thanks for the Hybrids library, I already modified my code. I'm doing a PWA of Notes only with the library (it's not finished yet), in the following link you can see it. click here (sorry for the spanish) |
There are some fix methods that cannot be used in the properties:
push
,pop
,shift
, ...For example click here
Sample error captures
Is Bad
Is Okay. 馃
The text was updated successfully, but these errors were encountered: