live input update, immutable data, handleChange and Ember rerender
See original GitHub issueHello,
It is not a bug, but a feature request.
I have a problem when I update
- a property
- of an item
- of a list in the state
by an input field
state
|- list
|- * item
{{#each list as |item|}}
{{input value=item.value key-press=(action update_item_value)}}
{{!-- trivial version just to understand my problem --}}
{{/each}}
=> the current component and all the parent components and pages are updated, because the state object is updated (it is immutable)
=> and so the {{#each}} helper refreshed the components of the list as well
=> and so the input is refreshed AND I LOOSE THE CURSOR POSITION !
Ember is not like ReactJS: without virtual hierarchy to compare, the real components are updated.
In connect > handleChange, we just check if the value of the property was changed, and when a property of an item of a list is changed, the list is changed too, so ember-redux notify this change.
So how to avoid to refresh everything ?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
The Component Lifecycle - Ember Guides
didUpdateAttrs runs when the attributes of a component have changed, but not when the component is re-rendered, via component.rerender , component.set ...
Read more >Ember component is not re-rendering on change of @tracked ...
I expect it to refresh when action saveRoles(updatedUserRoles) is used, since it depends on an @tracked variable. UserRoles is a component from ...
Read more >each re-render bug · Issue #16975 · emberjs/ember.js - GitHub
I have an array of true/false/undefined values which I am rendering as a list of checkboxes. When changing an array element to or...
Read more >Understanding Ember.js: The View Layer - GitHub Pages
This guide goes into extreme detail about the Ember.js view layer. ... as well as updating the contents of the DOM when the...
Read more >Top 65 React Interview Questions (2023) - Javatpoint
JSX; Components; One-way Data Binding; Virtual DOM; Simplicity; Performance ... Once the calculations are completed, the real DOM updated with only those ...
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 FreeTop 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
Top GitHub Comments
Hello,
With the solution of @sandersky, it works: https://ember-twiddle.com/ebfa40f96ba41659765a09b3715587c1/cffae11937938d033482c0cbb5c83ad85f350797?openFiles=components.my-list.js%2C
The first list has the “key” defined, and not the second one.
Thanks.
Frédéric
@wooandoo is there a unique identifier property on your list items that would allow you to do something like this:
If so, I’m curious if that would solve the issue you are seeing or if the issue still persists.