createAction adds strange `[32] ` characters to type
Arman92 opened this issue · comments
Here in createAction.js:47
Line 47 in afa5d6d
Why are you changing the action type to something strange? Of course, it would not be detected in the reducer.
I'm trying to use 'connected-react-router' and have a reducer on @@router/LOCATION_CHANGE
action type. but the action creator is changing it to [32] @@router/LOCATION_CHANGE
which then reducer fails to detect it.
This is a simplified code snippet for my use case:
const locationChanged = createAction('@@router/LOCATION_CHANG')
const handleLocationChanged = state => loop({ ...state }, Cmd.run(something....)
const actions = {
[locationChanged]: handleLocationChanged
}
const reducer = createReducer(actions, {})
That's the whole foundation of the lib: generate a unique id for each action to prevent any type collision.
I don't know about connected-react-router
but if the action already has a defined type, why do you need to create a new action?
const handleLocationChanged = state => loop({ ...state }, Cmd.run(something....)
const actions = {
['@@router/LOCATION_CHANGE']: handleLocationChanged
}
const reducer = createReducer(actions, {})
You are right. However I already tried this solution and got my answer, sorry for bothering!