Skip to content

Refactor Redux for Files in reducers,actions and components etc #3398

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Jatin24062005
Copy link
Contributor

Fixes #2042

Changes:
This pull request improves Redux state management by removing outdated ActionTypes from client/constants.js and replacing their usage with direct action creators from createSlice. It ensures that Redux state handling aligns with best practices from @reduxjs/toolkit, making the codebase more maintainable, modular, and efficient.

After reviewing referenced pull requests (#3121 - #3127), I found that Redux modernization was not fully applied in the base creation of slices. Some files still relied on ActionTypes, leading to inconsistencies in state management. This PR standardizes Redux implementation, removes unnecessary boilerplate, and optimizes the flow of state updates.

Key Changes & Improvements
Removed Outdated ActionTypes from client/constants.js

Eliminated unused Redux action type constants that were previously used for defining actions.
Replaced all occurrences of ActionTypes in various files with actions from createSlice.
Ensured that all Redux logic now uses a structured slice-based approach instead of manually handling action types.
Refactored Core Redux-Dependent Files
The following files were updated to remove direct usage of ActionTypes and replace them with Redux slice actions:

client/modules/IDE/components/FileNode.jsx

Replaced connect and mapStateToProps with useSelector and useDispatch.
Updated all Redux state updates to use slice-based action dispatching.
Improved component readability by reducing dependency on Redux constants.
client/modules/IDE/components/FileNode.unit.test.jsx

Refactored unit tests to work with the new Redux slice-based state management.
Removed direct dispatch of ActionTypes and replaced them with properly imported action creators.
Verified that existing test cases pass successfully after migration.
client/modules/IDE/actions/project.js

Refactored all Redux action creators to use createSlice instead of manually returning action objects.
Ensured that the project-related state management aligns with Redux Toolkit standards.
Removed redundant logic that was previously required for handling raw action types.
client/modules/IDE/actions/files.js

Migrated all file-related Redux actions to use slice reducers and actions.
Improved code organization by consolidating related logic within slices.
Ensured seamless integration with components that depend on file actions.
Refactored State Management for Maintainability

Simplified the logic for dispatching actions by using slice-based reducers.
Ensured consistency across files that interact with Redux state.
Removed redundant Redux boilerplate, reducing unnecessary complexity.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

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

Successfully merging this pull request may close these issues.

Refactoring Redux code: hooks, thunks, and redux-toolkit
2 participants