Just want to discuss this, since was confused by default actionCreator factory behaviour. As per docs if I define my action crator like that:
export const toggleBaseline = makeActionCreator('Dbg.TOGGLE_BASELINE')
identity function will be used for payload. I assumed that it's fine to create Action Creators that don't have a payload in this manner and it was wrong assumption. Read below why.
After creating it I passed it to my component like that:
export default connect(state => state.debug, {
toggleBaseline,
})(DebugGrid)
Then inside DebugGrid
component I just hooked it to onClick
handler:
<input type="checkbox" onChange={props.toggleBaseline}
All seemed fine, do you see a problem at this point? I didn't see any =) And if you don't see it also then we have a problem and need to do something about it. This is main point of this issue.
Then I opened Redux Dev Tools, clicked on my checkbox and saw this:
That was a moment of "whait a minute..." aha, right since Action Creator uses identity function and I pass it "as-is" to reduce boilerplate to my component event handler it grabs React's synthetic event to it's params, but why it becomes so slow, 400ms for an action dispatch?
Then I realized that default settings in Redux Dev Tools is to serialize state and that synthetic event object must be huge so serialization of it takes 300-400ms.
If I haven't used Dev Tools I would have not discovered this untill much later when I would be out of context and probably would spend days to figure this out.
So then I figured that default "safe" way to define Action Creators is like this:
makeActionCreator('Dbg.TOGGLE_BASELINE', () => {})
It looks a little weird to me, am I missing something? Thanks!