gcazaciuc / redux-fractal

Sane local component state & actions using Redux
MIT License
178 stars 13 forks source link

Implement `toJSON` for actions which include unserializable objects #94

Open hoschi opened 7 years ago

hoschi commented 7 years ago

In short: Redux devtools serialize actions and state. Action @@ui/CREATE_COMPONENT_STATE has the prop payload.props which can contain react nodes, which can't be handled by this serialization in some cases. To fix this implement toJSON and stub it out, see:

My use case which showed that bug: I added react-sticky-state to my app which is a child of a component in the node tree of one child in this payload.props.children property: 2017-07-11-154921_1026x1384_scrot

One of the nodes/props react-sticky-state has something it it that is not serializable. I temporary fixed it by excluding this action in redux devtools:

    if (process.env.NODE_ENV === 'development' && window.__REDUX_DEVTOOLS_EXTENSION__) {
        storeEnhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({
            serialize: {
                // save complex data types which are not serializable by default
                options: true,
            },
            actionsBlacklist: ['@@ui/CREATE_COMPONENT_STATE']
        }));
    }
hoschi commented 7 years ago

My workaround works not for the first time one opens the Chrome devtools and switches to redux panel, when app is already loaded.