redux state array bound to dom-repeat doesn't reflect items property changes.
See original GitHub issueI have the following element the issue is when changing an employee thru redux action, the changes does not propagate to the dom-repeat, but is reflected when bound directly inside the parent template (e.g. [[employees.0.id]]) I’ve tried manual re-render of the dom-repeat template e.g. this.$.employees.render() but still does not reflect the updated employee properties any suggestion?
Note: i’m using v1.01
<dom-module id="employees-info">
<template>
[[employees.0.id]] - [[employees.0.firstname]] -- [[employees.0.lastname]]
[[employees.1.id]] - [[employees.1.firstname]] -- [[employees.1.lastname]]
<template is="dom-repeat" items=[[employees]] as=“employee” id=“employees” >
<div>id: [[employee.id]]</div>
<div>firstname: [[employee.firstname]]</div>
<div>lastname: [[employee.lastname]]</div>
</template>
</template>
<script>
class EmployeesInfo extends ReduxMixin(Subscriber(Polymer.Element)) {
static get is() {
return 'employees-info'
}
static get properties() {
return {
employees:{
type:Array,
statePath:'employees'
}
}
}
}
customElements.define(EmployeesInfo.is, EmployeesInfo);
</script>
</dom-module>
Now inside the redux store actions, (i’ve already tried multiple ways to update the array e.g. splice)
```
case 'UPDATE_EMPLOYEE_SUCCESS':
return Object.assign({}, state, {
employees: state.employees.slice().map((employee) =>{
// update employee bere
return employee;
}), updating_employee: 'success' });
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
How to update single value inside specific array item in redux
I have an issue where re-rendering of state causes ui issues and was suggested to only update specific value inside ...
Read more >Few Ways to Update a State Array in Redux Reducer - Medium
In React and Redux it's said to keep the state immutable. It simply means that we should not change the state properties directly....
Read more >When does React re-render components? - Felix Gerschau
Changing the state means that React triggers an update when we call the setState function (in React hooks, you would use useState )....
Read more >Angular NgRx Entity - Complete Practical Guide
if we store all our entities as arrays, our reducers will look almost the same for every entity. For example, take the simple...
Read more >Udacity React & Redux - James Priest CV
Since Redux is not a topic for beginners and can be a daunting area to ... The actions represent the different events that...
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
Plus one this issue. I am facing the same problem. sub properties are not notified on change.
On Polymer 2 there is another solution. It’s to use “mutable-data” in the template dom-repeat.
The problem i found is to notify changes to children elements of the dom-repeat. Like this:
In this case
<todo-item>
do not change, even of the mutable-data configuration on dom-repeat. This situation is solved using the Polymer.MutableData mixin on<todo-item>
.I dont know the performance of this solution. (Worried because with any minimal change in the array causes a notification of change in all the items in the dom-repeat, even if only has changed one of them)