Skip to content

Remove Higher Order Components from Editors #2089

@bradenmacdonald

Description

@bradenmacdonald

In src/editors/...

  1. Replace injectIntl with useIntl() -> Replace the deprecated injectIntl with the useIntl() hook #2280
  2. Replace usage of connect with useSelector() and useDispatch() -> Replace usage of connect with useSelector() and useDispatch() #2312
  3. Update the code and tests to get rid of the Internal export pattern:
    Example of exporting (Component)Internal and Component = injectIntl(connect(...)) HOCs, then testing with the Internal one.

export const AnswerOptionInternal = AnswerOption; // For testing only
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(memo(AnswerOption)));

import { AnswerOptionInternal as AnswerOption, mapStateToProps } from './AnswerOption';

Once the HOCs (injectIntl, connect) are replaced with hooks, if it's necessary to mock redux state in tests, convert the tests to use initializeMocks from src/testUtils.tsx and pass in initialState to initializeMocks. Or use const { reduxStore } = initializeMocks(); and dispatch changes to the redux store.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code healthProactive technical investment via refactorings, removals, etc.good first issueA good task for a newcomer to start withhelp wantedReady to be picked up by anyone in the community

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions