Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Uncaught Error: Your custom UI reducer at path X must return some state #54

Open
economysizegeek opened this issue Aug 10, 2016 · 1 comment

Comments

@economysizegeek
Copy link

I have two components that are nested Issues -> IssueCard. They each have their own customer reducers defined. When I unmount them - I get this error on the IssueCard path for the custom reducer.

The problem seems to be in action-reducer.js line ~144
var newState = func(mut.getIn(path), action);
if (newState === undefined) {
throw new Error('Your custom UI reducer at path ' + path.join('.') + ' must return some state');
}

The parent Issues gets unmounted this seems to wipe out the UI state for the child. Then it runs a second UI_UMOUNT_UI_STATE - it tries to run the custom reducer on a IssueCard (The state is undefined) and it returns undefined so the error trips.

This seems corrected by confirming that the existing state isn't already undefined before complaining:
if (newState === undefined && mut.getIn(path) !== undefined) {
throw new Error('Your custom UI reducer at path ' + path.join('.') + ' must return some state');
}

@tpinne
Copy link

tpinne commented Apr 25, 2017

I'm having the same problem. But in my case the nested component doesn't get unmounted. It only runs one @@redux-ui/UPDATE_UI_STATE action setting one value and then the console prints the error message.
As long as I can trust the redux dev tools in this case.

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

No branches or pull requests

2 participants