Replace deprecated injectIntl HOC with useIntl-based shim#1724
Open
a-limyr wants to merge 1 commit into
Open
Conversation
…built on the supported useIntl hook and repoint all 52 imports to it, so legacy class components keep working without conversion.
|
|
Preview for this PR in https://ent-ror-abzu-dev--preview-1724-feature-migrate-injecti-zfwo76gt.web.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



##Title
Replace deprecated injectIntl HOC with useIntl-based shim
Why
react-intlremoved theinjectIntlHOC (deprecated in v8, gone by v9/v10). Our codebaseuses
injectIntlin 52 files, so the pendingreact-intlv10 bump(
renovate/major-formatjs-monorepo) currently fails to build:error TS2305: Module '"react-intl"' has no exported member 'injectIntl'.
and crashes at runtime (
TypeError: injectIntl is not a function).This PR unblocks that bump without changing the dependency itself, so the version
upgrade stays a clean, isolated Renovate PR.
What
src/utils/injectIntl.tsx— a small, typed HOC that reads the supporteduseIntl()hook and injectsintlas a prop, reproducing react-intl's oldinjectIntlbehaviour.
react-intlto the local shim. Of these, 46 are legacyclass components that cannot use the
useIntlhook directly — the shim lets them keepworking unchanged rather than requiring a risky class-to-function rewrite.
package.json/ lockfile are intentionally untouched — the react-intl version bumpremains in its own Renovate PR.
Approach note
A shim was chosen over converting 46 class components to hooks: it keeps this PR mechanical,
behaviour-preserving, and trivially reviewable. New code should still prefer the
useIntlhook directly (noted in the shim's doc comment).
Verification
Build, tests, and Prettier all pass — confirmed against both react-intl versions:
npm run build(tsc+ vite)npm run testnpm run check(Prettier)v10 compatibility was verified by transiently installing
react-intl@10.1.13(withoutsaving) and re-running build + tests. Test count rises 139 → 142 because
ModalitiesMenuItems.spec.jsno longer crashes on import.Merge order
Merge this first; the
react-intlv10 Renovate PR then rebases to a clean one-line bump.