question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible feature: have handleAction() transfer payload to state when reducer is undefined

See original GitHub issue

This could be a really bad idea, but I thought I’d run it by you. I often find that I’m just wanting to write a quick reducer that just moves the action’s payload to the state. Being able to just type:

const reducer = handleAction(ACTION_TYPE, initialState);

instead of

const reducer = handleAction(ACTION_TYPE, (_, {payload}) => payload, initialState);

would be really nice. Just a thought.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yangmillstheorycommented, Sep 1, 2016

I think it belongs in userland. Just define a reusable helper in your code:

const noopFSAReducer = (state, { payload }) => payload 

export default noopFSAReducer
0reactions
timchecommented, Sep 6, 2016

Closing it then for now, feel free to comment in here to re-open this feature request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add optional behavior to pass payload to reducer #98 - GitHub
but it'd be nice if handleAction(s) supported reducers that just take ... Possible feature: have handleAction() transfer payload to state ...
Read more >
Why does my reducer parameter type accepts `undefined`?
The issue is about the payload type inside handleActions . Its type is ProductActionProps | undefined . I have to check whether payload...
Read more >
Redux Fundamentals, Part 3: State, Actions, and Reducers
The official Redux Fundamentals tutorial: learn how reducers update state in response to actions.
Read more >
Setting Up Redux For Use In A Real-World Application
The setUser reducer function accepts a payload containing user data and updates the state with it. When no data is passed, we set...
Read more >
Actions and reducers: updating state - Human Redux
Redux reducer rule #1: You may never return undefined , so you always have to return something, even if it's null . Returning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found