-
Notifications
You must be signed in to change notification settings - Fork 196
Remove Higher Order Components from Editors #2089
Copy link
Copy link
Open
Labels
code healthProactive technical investment via refactorings, removals, etc.Proactive technical investment via refactorings, removals, etc.good first issueA good task for a newcomer to start withA good task for a newcomer to start withhelp wantedReady to be picked up by anyone in the communityReady to be picked up by anyone in the community
Metadata
Metadata
Assignees
Labels
code healthProactive technical investment via refactorings, removals, etc.Proactive technical investment via refactorings, removals, etc.good first issueA good task for a newcomer to start withA good task for a newcomer to start withhelp wantedReady to be picked up by anyone in the communityReady to be picked up by anyone in the community
In
src/editors/...injectIntlwithuseIntl()-> Replace the deprecated injectIntl with the useIntl() hook #2280connectwithuseSelector()anduseDispatch()-> Replace usage of connect with useSelector() and useDispatch() #2312Internalexport pattern:Example of exporting
(Component)InternalandComponent = injectIntl(connect(...))HOCs, then testing with theInternalone.frontend-app-authoring/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.jsx
Lines 173 to 174 in 5df4cd9
frontend-app-authoring/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.test.jsx
Line 6 in 5df4cd9
Once the HOCs (
injectIntl,connect) are replaced with hooks, if it's necessary to mock redux state in tests, convert the tests to useinitializeMocksfromsrc/testUtils.tsxand pass ininitialStatetoinitializeMocks. Or useconst { reduxStore } = initializeMocks();and dispatch changes to the redux store.