Skip to content

Switch to modern React contexts #1083

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Jun 13, 2025

We use React's context API to pass around instances of the API services for different components to use, but depended on React's original context API, which was deprecated 7 years ago and was fully removed in React v19 last year. This switches to the new API. It's a little hacky: the new API only allows class components to use a single context, when it would be nice to have separate contexts for the DB and local APIs. But we frequently use them together, so I just a single context that contains both.

We use React's context API to pass around instances of the API services for different components to use, but depended on React's original context API, which was deprecated 7 years ago. This switches to the new API. It's a little hacky -- the new API only allows class components to use a single context, when it would be nice to have separate contexts for the DB and local APIs. But we frequently use them together, so I just a single context that contains both.
"ecmaVersion": 2020,
"ecmaVersion": 2022,
Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I think it would be fine to bring this up even farther! We haven’t refreshed things here in a long time. But this is the minimum needed for the syntax I wanted to leverage in this PR, and should be completely safe. Works both in Node 18 (we should also upgrade that) and all shipping browsers for a while.

@Mr0grog Mr0grog merged commit 87eb100 into main Jun 13, 2025
5 checks passed
@Mr0grog Mr0grog deleted the legacy-contexts-are-no-longer-our-legacy branch June 13, 2025 23:32
@github-project-automation github-project-automation bot moved this from Inbox to Done in Web Monitoring Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant