Possible feature: have handleAction() transfer payload to state when reducer is undefined
See original GitHub issueThis 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:
- Created 7 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it belongs in userland. Just define a reusable helper in your code:
Closing it then for now, feel free to comment in here to re-open this feature request.