Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Redux logic setup to use Redux Toolkit #637

Open
markerikson opened this issue Nov 18, 2019 · 4 comments
Open

Switch Redux logic setup to use Redux Toolkit #637

markerikson opened this issue Nov 18, 2019 · 4 comments

Comments

@markerikson
Copy link

Hi, I'm a Redux maintainer. I'd like to offer a couple suggestions.

Is your feature request related to a problem? Please describe.

The current Redux example implementation shows use of reducers with "hand-written" immutable update logic, and has a somewhat complex store configuration. In addition, the project currently uses a "folder-by-type" folder structure.

Describe the solution you'd like

The project should switch to using the official Redux Toolkit package to implement the Redux logic.

The project should also consider switching to a "feature-folder" or "ducks" folder structure, rather than a "folder-by-type" structure.

Additional context

Redux Toolkit is our new official, opinionated, batteries-included toolset for efficient Redux development. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once without writing any action creators or action types by hand.

We are recommending RTK as the default standard way to write Redux logic. Partly related to that, we are also recommending that developers should prefer to use "feature folders" or "ducks" rather than "folder-by-type". (Reference: the work-in-progress Redux "Style Guide" docs page.)

Since many developers will be starting their projects using react-slingshot, it would be beneficial if Redux Toolkit was included as part of the default project setup, as it will greatly simplify the application code they write.

@nickytonline
Copy link
Collaborator

Thanks for opening this issue Mark and thanks for all that you’ve done in Redux land.

I’m definitely down with this, but, It’d be good to get @coryhouse and @kwelch chime in on this as well.

@markerikson
Copy link
Author

FWIW, I've cloned the repo and am currently playing around with trying to do the conversion.

Honestly, the biggest problem atm appears to be the heavy reliance on import * as ActionTypes from '../constants/actionTypes'; in store.spec.js :)

Switched out the store config only took me about 5 minutes. I may just try adding an equivalent features/fuel/fuelSlice.js file for point of comparison, rather than trying to port all the logic and the tests.

@markerikson
Copy link
Author

Another point in favor of switching to RTK: the current setup adds redux-thunk and redux-immutable-state-invariant, which RTK already adds to its store setup by default.

@markerikson markerikson mentioned this issue Nov 18, 2019
7 tasks
@markerikson
Copy link
Author

PR is up. I made some additional stylistic-ish changes. I'd appreciate it if you'd consider them, but you may ignore them if desired.

Also, there's some prior discussion on the folder structure at #146 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants