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.

handleActions naming is confusing

See original GitHub issue

Since handleActions returns a reducer, a proper name for it would be createReducer. I’ve tried to teach redux to a friend and it wasn’t immediately apparent that handleActions returns a reducer. What do you think? I’m not adamant on createReducer, as it doesn’t differentiate from handleAction. I just think that handleActions might not be the proper name for it.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:4
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
doliver3commented, Jan 3, 2016

Recommendations: A better name for createAction is actionCreator since it generates an actionCreator A better name for handleActions is actionReducers since it generates reducers.

This lines up with existing naming conventions: http://redux.js.org/docs/basics/Actions.html - Action Creators http://redux.js.org/docs/basics/Reducers.html - Reducers handle Actions

The react-redux-starter-kit just added the ‘redux-actions’ names to its module/counter file as it turned 1.0 recently, and as someone new to Redux I would agree that the naming of ‘redux-actions’ was not intuitive and it was significantly different than the Redux example projects. Only the comments made it clear what each was.

5reactions
shark0dercommented, Dec 28, 2015

I’d add on this. Let’s take this code straight from the documentation:

let increment = createAction('INCREMENT');

Any person that would see this for the first time would assume that increment is now an action. Well… bad news, increment is now an action creator therefore an actually descriptive name for createAction in this case would be createActionCreator, which reminds me of this: http://bash.org/?946461.

Please come up with some proper names 😞.

Read more comments on GitHub >

github_iconTop Results From Across the Web

redux-actions handleActions isn't changing the state
You are passing map with wrong keys to handleActions . You don't want keys to be SET and CLEAR , but their values...
Read more >
Redux Best Practices - Medium
Structure and Naming. Use Ducks. Note: Dan does not endorse ducks because it may confuse beginners into thinking actions map 1:1 to reducers....
Read more >
handleAction(s) - redux-actions
If a reducer function is passed, it is used to handle both normal actions and failed actions. (A failed action is analogous to...
Read more >
Transfering states in react - JavaScript - The freeCodeCamp Forum
handleAction , a class method in Parent. It is being passed in (on the left side) in the prop “handleAction”. I gave the...
Read more >
REST Resource Naming Guide
To avoid this confusion, use hyphens (-) instead of underscores ( _ ). http://api.example.com/inventory-management/managed-entities/{id}/install ...
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