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

dynamic reducers can not work with combineReducers #3643

Closed
H3lloTom opened this issue Nov 30, 2019 · 3 comments
Closed

dynamic reducers can not work with combineReducers #3643

H3lloTom opened this issue Nov 30, 2019 · 3 comments

Comments

@H3lloTom
Copy link

H3lloTom commented Nov 30, 2019

Do you want to request a feature or report a bug?

bug

Bug Reports

i have an app, whats reducer is dynamic. the reducer is combined by combineReducers,but combineReducers seems have a cache Strategy, if new reducer map have the same result in old state, after traversal, it will return old state.even if the new reducer map has less reducer key than old reducer map, in this case i want to get exact next state after i invoke replaceReducer.🙂

What is the current behavior?

combineReducers return old state in the case next reducer map has less key than previous reducer map.

Steps to Reproduce

👉 https://codesandbox.io/s/interesting-chandrasekhar-h56kh?fontsize=14&hidenavigation=1&theme=dark 👈

What is the expected behavior?

combineReducers return next state in the case: next reducer map has less key than previous reducer map.

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?

redux 4.0.4

What docs changes are needed to explain this?

if combineReducers could not work with replaceReducer in this case, i wish could got a office notice😁

@markerikson
Copy link
Contributor

markerikson commented Nov 30, 2019

combineReducers has had a special check for the REPLACE action for over two years, so it's not like this is a recent change: #2673

However, I do agree this is rather unexpected from the user's point of view.

@timdorr, thoughts?

@H3lloTom
Copy link
Author

🎉🎉🎉thanks for replying so quickly ,but i could only find a special check for REPLACE action in warningMessage,

it seems still have my situation,while i do replaceReducer with a less reducer map
(the old reducercombineReducers({a:()=>'a',b:()=>'b'}) => new reducercombineReducers({a:()=>'a'})),

the combineReducers returned combination func deal REPLACE action, still return old state {a:'a',b:'b'},meanwhile,b is not in my new reducer🤔

@timdorr
Copy link
Member

timdorr commented Nov 30, 2019

Duplicate of #3488 and was fixed in #3490, but we haven't released it yet.

@timdorr timdorr closed this as completed Nov 30, 2019
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

3 participants