Skip to content

Refactoring Redux code: hooks, thunks, and redux-toolkit #2042

Open
@lindapaiste

Description

@lindapaiste

Most of the Redux code is this package was written years ago and has not been touched since. In that time, Redux has come a long way! The bad news is that this codebase goes against a lot of the Redux Best Practices. The good news is that the newer ways of doing things are much easier and involve a lot less boilerplate.

Some things which can be improved/changed:

  • Can use createSlice which automatically creates the action creators for a reducer so that you don't need to define a bajillion constants or define basic action creator functions. This can be tackled one "slice" at a time, as Redux Toolkit is fully compatible with old/vanilla Redux.
  • Can use createAsyncThunk to automatically dispatch pending, error and fulfilled actions for each asynchronous action.
  • Can use useSelector and useDispatch hooks instead of the connect HOC.

I can do a lot of this myself, but I wanted to post it as a discussion first because I don't want to waste time rewriting code if it's not wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementImprovement to an existing featurePriority:HighShould be addressed soon but not criticalType:TaskTasks tied specifically to developer operations and maintenance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions