popcodeorg / popcodeorg/popcode

Implement reducers with handleActions

Open
#1,690 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code quality
Dominant language
JavaScript
Stars
191
Forks
143
Avg merge
4d 11h
Merged PRs (30d)
5

Description

Currently most of our reducers are implemented as a big switch statement, which is unwieldy and hard to read. Instead, use the handleActions() helper in redux-actions to implement the reducer as a map of action names to reducer functions.

We should follow the pattern of using the action creator function itself as the map key, allowing us to avoid hard-coding string literals containing the action name.

See the console reducer for an example of the desired implementation.

Testing

Since our goal here is merely to refactor the reducers, not change their behavior, all existing tests should pass after a reducer is refactored.

However, it might make sense to also port the reducer test to Jest after completing the refactor and confirming that the old tests pass with the new reducer implementation (this should be in separate commits).

Reducers to migrate
  • clients
  • compiledProjects
  • console
  • currentProject
  • errors
  • googleClassroom
  • index
  • projects
  • resizableFlex
  • ui
  • user

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the completed example in src/reducers/console.js, then locate the unchecked clients, compiledProjects, currentProject, errors, googleClassroom, index, projects, and user reducers. Refactor them with redux-actions while preserving behavior, and run all existing tests to confirm they still pass; leave Jest test porting for a separate change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, redux
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.