destroyIntl

destroyIntl(scope?) disposes runtime resources.

Use this for component/page teardown in long-lived single-page contexts.

ts
1import { createIntl, destroyIntl } from '@beforesemicolon/intl'2 3const preview = createIntl({ locale: 'en-US' })4destroyIntl(preview)

Signature

ts
1function destroyIntl(scope?: IntlRuntime): void

What it does

If no scope is passed, it disposes the package default runtime only when it is the current default.

ts
1import { destroyIntl } from '@beforesemicolon/intl'2 3destroyIntl() // remove package default runtime

Teardown patterns

Scoped runtime

Use with modals, widgets, and editors that own their own localization context.

ts
1const sidePanelRuntime = createIntl({ locale: 'en-US', messages: { ok: 'OK' } })2// ... modal closes3destroyIntl(sidePanelRuntime)

Default runtime

Use during app-level unmount or full-page reload flows.

ts
1window.addEventListener('beforeunload', () => destroyIntl())

What it is not

destroyIntl() does not mutate any other runtime instances. For default runtime reset in test code, prefer resetIntl().

edit this doc