redux-utilities / redux-actions

Flux Standard Action utilities for Redux.
https://redux-actions.js.org
MIT License
6.51k stars 301 forks source link

createAction not accepting null as second argument #169

Closed Bouncey closed 7 years ago

Bouncey commented 7 years ago

I have just tried to v1.0.1 and I am getting this error stack.

Throws this error stack

Failed loading boot script: /home/stuart/freecodecamp/server/boot/react.js
Invariant Violation: Expected payloadCreator to be a function or undefined
    at invariant (/home/stuart/freecodecamp/node_modules/invariant/invariant.js:42:15)
    at createAction (/home/stuart/freecodecamp/node_modules/redux-actions/lib/createAction.js:30:27)
    at Object.<anonymous> (/home/stuart/freecodecamp/common/app/redux/actions.js:24:27)
    at Module._compile (module.js:570:32)
    at loader (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function._load (/home/stuart/freecodecamp/node_modules/pmx/lib/transaction.js:62:21)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/stuart/freecodecamp/common/app/routes/challenges/components/map/Challenge.jsx:12:1)
    at Module._compile (module.js:570:32)
    at loader (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .jsx] (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:154:7)
Invariant Violation: Expected payloadCreator to be a function or undefined
    at invariant (/home/stuart/freecodecamp/node_modules/invariant/invariant.js:42:15)
    at createAction (/home/stuart/freecodecamp/node_modules/redux-actions/lib/createAction.js:30:27)
    at Object.<anonymous> (/home/stuart/freecodecamp/common/app/redux/actions.js:24:27)
    at Module._compile (module.js:570:32)
    at loader (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function._load (/home/stuart/freecodecamp/node_modules/pmx/lib/transaction.js:62:21)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/stuart/freecodecamp/common/app/routes/challenges/components/map/Challenge.jsx:12:1)
    at Module._compile (module.js:570:32)
    at loader (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .jsx] (/home/stuart/freecodecamp/node_modules/babel-register/lib/node.js:154:7)

The actions causing the error are in this format

export const toggleMapDrawer = createAction(
  types.toggleMapDrawer,
  null,
  () => createEventMeta({
    category: 'Nav',
    action: 'toggled',
    label: 'Map drawer toggled'
  })
);

Any advice would be greatly appreciated

yangmillstheory commented 7 years ago

Invariant Violation: Expected payloadCreator to be a function or undefined

Could you pass undefined instead of null? After a long discussion, we decided not to have null and undefined mean the same things in this context.

Bouncey commented 7 years ago

Our linting is against undefined, I will discuss with our other maintainers :+1:

yangmillstheory commented 7 years ago

@Bouncey Let me discuss this with @timche (unfortunately it's past midnight in Germany, where he's located). I had some reservations merging this constraint, and I don't think it should inconvenience your team this much. I'd like to allow null again.

Can you downgrade for now?

Bouncey commented 7 years ago

I was just testing out the greenkeeper PR, it isn't merged just yet

yangmillstheory commented 7 years ago

v1.1.0 is out, and supports null payload creators once again.

Bouncey commented 7 years ago

Thanks for the quick turn around :+1:

BerkeleyTrue commented 7 years ago

@Bouncey Thanks for pointing this out.