Skip to content

Replace deprecated injectIntl HOC with useIntl-based shim#1724

Open
a-limyr wants to merge 1 commit into
masterfrom
feature/migrate-injectintl-to-useintl
Open

Replace deprecated injectIntl HOC with useIntl-based shim#1724
a-limyr wants to merge 1 commit into
masterfrom
feature/migrate-injectintl-to-useintl

Conversation

@a-limyr

@a-limyr a-limyr commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

##Title

Replace deprecated injectIntl HOC with useIntl-based shim

Why

react-intl removed the injectIntl HOC (deprecated in v8, gone by v9/v10). Our codebase
uses injectIntl in 52 files, so the pending react-intl v10 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

  • New: src/utils/injectIntl.tsx — a small, typed HOC that reads the supported
    useIntl() hook and injects intl as a prop, reproducing react-intl's old injectIntl
    behaviour.
  • Repointed all 52 imports from react-intl to the local shim. Of these, 46 are legacy
    class components that cannot use the useIntl hook directly — the shim lets them keep
    working unchanged rather than requiring a risky class-to-function rewrite.
  • The change is purely import lines (+53/−52); no component logic touched.
  • package.json / lockfile are intentionally untouched — the react-intl version bump
    remains 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 useIntl
hook directly (noted in the shim's doc comment).

Verification

Build, tests, and Prettier all pass — confirmed against both react-intl versions:

Check v7.1.14 (current) v10.1.13 (forward-compat)
npm run build (tsc + vite)
npm run test ✅ 142/142 ✅ 142/142
npm run check (Prettier)

v10 compatibility was verified by transiently installing react-intl@10.1.13 (without
saving) and re-running build + tests. Test count rises 139 → 142 because
ModalitiesMenuItems.spec.js no longer crashes on import.

Merge order

Merge this first; the react-intl v10 Renovate PR then rebases to a clean one-line bump.

…built on the supported useIntl hook and repoint all 52 imports to it, so legacy class components keep working without conversion.
@a-limyr a-limyr changed the title react-intl removed the injectIntl HOC (gone by v9). Add a local shim built on the supported useIntl hook and repoint all 52 imports to it, so legacy class components keep working without conversion. Replace deprecated injectIntl HOC with useIntl-based shim Jun 25, 2026
@testower testower closed this Jun 29, 2026
@testower testower reopened this Jun 29, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Preview for this PR in dev (updated for commit c1f9b20):

https://ent-ror-abzu-dev--preview-1724-feature-migrate-injecti-zfwo76gt.web.app
(Expires Mon, 06 Jul 2026 11:39:01 GMT)

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.

2 participants