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

mapStateToProps and mapDispatchToProps often include unused props #2179

Open
lindapaiste opened this issue Mar 23, 2023 · 0 comments
Open

mapStateToProps and mapDispatchToProps often include unused props #2179

lindapaiste opened this issue Mar 23, 2023 · 0 comments
Labels
Area: Code Quality Area:Optimization Category for site performance optimization and management

Comments

@lindapaiste
Copy link
Collaborator

Related to #824 and #2042

I've noticed that a lot of components are accessing props through the Redux connect HOC which are not actually used in the component itself. The mapStateToProps and mapDispatchToProps don't get checked for unnecessary fields in the way that the PropTypes definitions do so it can be hard to spot them.

For example, the IDEView gets the editorAccessibility state and all EditorAccessibilityActions but does not use any of them.

The bulk importing of action creator objects with the import * as EditorAccessibilityActions from '../actions/editorAccessibility'; syntax makes it extra difficult to see which of those actions, if any, are actually used.

This is one of many reasons that the hooks are better, but we still have a lot of class component that can't use hooks yet.

FYI, the mapDispatchToProps setup with bindActionCreators is not necessary because you can use the object notation to pass the action creators without binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Code Quality Area:Optimization Category for site performance optimization and management
Projects
None yet
Development

No branches or pull requests

2 participants