|
|
|
|
|
by megous
1798 days ago
|
|
With react you've just moved your imperative code from REST->DOM manipulation to REST->local state manipulation and local state -> DOM mapping. You have to invent some elaborate local state schema and then map it to DOM, instead of keeping part of the state implicitly stored in DOM, where it makes sense. You can assign your data directly to DOM node objects. Say `el.yourData = todo_item`. And then let the order and list of items be kept implicitly in DOM, so you can do obvious things like remove nodes using `.remove()` reorder them via DnD, and whenever you need the list as data, you just querySelectorAll('.item').map(el => el.yourData) and you have your list. All quite straightforward. You can also do context dependent things by being able to travel up to the ancestors via parentNode. Declarative frameworks like react make simple things like this painful in comparison. |
|