1.1.1 • Published 10 months ago
@just-web/react-intl v1.1.1
@just-web/react-intl
@just-web/react-intl provides react-intl support for @just-web applications.
It re-exports react-intl so that you can access all functionality of react-intl directly.
Install
@just-web/react-intl needs @just-web/react
# npm
npm install @just-web/react-intl @just-web/react
# yarn
yarn add @just-web/react-intl @just-web/react
# pnpm
pnpm install @just-web/react-intl @just-web/react
#rush
rush add -p @just-web/react-intl @just-web/react
Usage
import { justApp } from '@just-web/app'
import { reactGizmo } from '@just-web/react'
import { reactIntlGizmoFn } from '@just-web/react-intl'
const app = await justApp({ name: 'your-awesome-app' })
.with(reactGizmo)
.with(reactIntlGizmoFn({ config: { locale: 'en', messages: {} } }))
.create()
app.react_intl.intl.formatMessage({ defaultMessage: 'hello world' })
function App() {
<JustAppProvider app={app}><Component/></JustAppProvider>
}
function Component() {
const intl = useIntl()
// or
// const app = useJustAppContext()
// const intl = app.react_intl.intl
return <div>{intl.formatMessage({ defaultMessage: 'hello world' })}</div>
}