Closed maikdiepenbroek closed 8 years ago
I am working on separating redux-immutable
into two packages. The base, which simply enables use of Immutable.js and canonical-reducer-composition mapper.
In the mean time, see https://github.com/gajus/canonical-reducer-composition#flux-standard-action.
Ok, cool! Will look into redux-convention, thanks for the quick response :dash:
using redux-convention converts the action to FSA but then validateAction.js throw an error: ncaught Error: Action definition object must define "name" property.
Since the action is now a FSA object ... or are we supposed to convert to FSA somewhere else?
I couldnt get the middleware to work also
So atm staying on redux 2.0.0
+1, I tried the redux-conection middleware solution but can't get it to work. I'm getting an error like this:
Ignoring private action "@@redux/INIT". redux-immutable does not support state inflation. Refer to https://github.com/gajus/canonical-reducer-composition/issues/1.
This is my first redux & first immutable project, I came to redux-immutable because I want to use some composition of my reducer, but the only solution I see now is giving all my actions both names and types, which is a bit ugly .. hmm
When you add name and type to the action, you'll get a different warning telling you that unknown properties aren't allowed.
Just use redux 2.x On Nov 26, 2015 2:35 PM, "Maik Diepenbroek" notifications@github.com wrote:
When you add name and type to the action, you'll get a different warning telling you that unknown properties aren't allowed.
— Reply to this email directly or view it on GitHub https://github.com/gajus/redux-immutable/issues/9#issuecomment-159821745 .
Yes I noticed that name + type is not an option either. Redux 2 meant downgrading React-redux aswell, so I ended up using a different package called immutable-reducers which now works perfect for me.
Not relevant in redux-immutable@2.0.1
.
@gajus Cool, thanks for the update!
I did a middleware workaround for this limitation. Might be useful to someone:
function fallbackTypeMiddleWare ({ getState }) {
return (nextMiddleWare) => (action) => {
if(!action.type){
action.type = "MY_DEFAULT_ACTION_TYPE";
}
let returnValue = nextMiddleWare(action);
return returnValue;
};
};
let store = createStore(
myInitialData,
applyMiddleware(fallbackTypeMiddleWare)
)
The above code is slightly modified from when I tested it so might be typos. The above allows me to use functions as actions (not in the thunk
way) like this:
store.dispatch( state => {
return { ...state, my_modification };
});
Not very redux-idiomatic but I find this more succinct in a nice way.
Since redux 3.0.0 action creators require the 'type' property not to be undefined, i've played around with it and just added it with the same value as the 'name' property to get rid of the error.
The error thrown: Uncaught Error: Actions may not have an undefined "type" property. Have you misspelled a constant?