Skip to content

Replace connect with useSelector() and useDispatch() 2/5 #2314 #2333

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 4 commits into
base: master
Choose a base branch
from

Conversation

ahtesham-quraish
Copy link
Contributor

@ahtesham-quraish ahtesham-quraish commented Jul 28, 2025

Description

Replace connect with useSelector() and useDispatch() 2/5 #2314

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for manually testing this change.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.45%. Comparing base (0e1550a) to head (eb476c8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2333   +/-   ##
=======================================
  Coverage   94.44%   94.45%           
=======================================
  Files        1169     1169           
  Lines       25102    25130   +28     
  Branches     5473     5490   +17     
=======================================
+ Hits        23708    23736   +28     
+ Misses       1328     1322    -6     
- Partials       66       72    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 70 to 74
// const showAdvancedSettingsCardsBaseProps = {
// isAdvancedCardsVisible: false,
// showAdvancedCards: jest.fn(),
// setResetTrue: jest.fn(),
// };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this or any unnecessary comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2314 branch 2 times, most recently from 4a5c655 to 0cfc7f8 Compare July 30, 2025 09:47
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! It's a nice refactor and I'm excited to have this in place. However, could you please make sure to review #2343 and rebase this on top of it, before proceeding?

beforeEach(() => {
initializeMocks();
initializeMocks({
initialState,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing initialState twice (to initializeMocks and editorRender) is redundant - please see the fixes in #2343

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the initialState from initializeMocks

@@ -17,6 +17,49 @@ jest.mock('./settingsComponents/SwitchEditorCard', () => 'SwitchEditorCard');
jest.mock('./settingsComponents/TimerCard', () => 'TimerCard');
jest.mock('./settingsComponents/TypeCard', () => 'TypeCard');

jest.mock('../../../../../data/redux', () => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare this using the EditorState type (or PartialEditorState from #2343) so we know that the types are valid. I suspect there are some issues here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used the PartialEditorState from #2343 you can check that

@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2314 branch 5 times, most recently from a9ab34f to a414746 Compare August 4, 2025 11:05
@ahtesham-quraish
Copy link
Contributor Author

ahtesham-quraish commented Aug 4, 2025

@bradenmacdonald thank you for highlighting the typed issues I have tried to fix them in my current PR and will fix the remaining ones in follow-up PRs. I have gone through the #2343 and approved it, after its merge I will rebase my branch

@bradenmacdonald
Copy link
Contributor

Thanks @ahtesham-quraish. I've merged it now so you can rebase this branch.

@ahtesham-quraish
Copy link
Contributor Author

@bradenmacdonald I have rebased my branch with #2343 please re-review my PR

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

Successfully merging this pull request may close these issues.

3 participants