Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lore-reducers] cid not updated across all reducers when normalized data overwrites paginated data #180

Open
jchansen opened this issue Sep 12, 2018 · 0 comments

Comments

@jchansen
Copy link
Contributor

The follow appears to be true (though the order might be reversed, need to debug more):

If you make an api request using getState('modelA.find'), the data in the store might look like this:

store.modelA = {
  byId: { id:1, cid: 'c1'}
  byCid: { id:1, cid: 'c1'},
  find: { data: [{id:1, cid: 'c1'}] }
}

Then fetch a single modelB, that contains a modelA (nested in the result), like getState('modelB.byId', { id: 123 }). The store will be updated to look like this:

store.model = {
  byId: { id:1, cid: 'c2'}
  byCid: { id:1, cid: 'c2'},
  find: { data: [{id:1, cid: 'c1'}] }
}

The cid values no longer match. The byId and byCid reducers seem to stay in sync, but the find reducer has a different value.

It might actually be that the getState.byId call is made first followed by the getState.byCid call though...either way, this seems to be happening.

Side effects appear to include React issuing a warning about duplicate keys when it occurs (when rendering a list of items), though it won't render the duplicate items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant