Use injectI18n Higher-Order Component instead of I18nContext#20542
Use injectI18n Higher-Order Component instead of I18nContext#20542yankouskia merged 3 commits intoelastic:masterfrom
Conversation
💚 Build Succeeded |
💚 Build Succeeded |
azasypkin
left a comment
There was a problem hiding this comment.
LGTM, just few nits, thanks!
Also please update PR title (and name of squashed commit) to reflect what is actually done in this PR.
packages/kbn-i18n/README.md
Outdated
| wrap your components into `I18nContext` component. The child of this component | ||
| should be a function that takes `intl` object into parameters: | ||
|
|
||
| React wrapper provides an ability to inject the imperative formatting API into a React component via its props using `injectI18n` HOC. This should be used when your React component needs to format data to a string value where a React element is not suitable; e.g., a `title` or `aria` attribute. In order to use it you should wrap your component into `injectI18n` function. The formatting API will be provided to the wrapped component via `props.intl`. |
There was a problem hiding this comment.
nit: HOC --> higher-order component (HOC) factory
nit: should wrap your component into `injectI18n` function --> should wrap your component with `injectI18n` factory
|
|
||
| ```js | ||
| import React from 'react'; | ||
| import { ReactI18n } from '@kbn/i18n'; |
There was a problem hiding this comment.
note: don't forget to update this example in #20513 (or after it's merged, up to you).
There was a problem hiding this comment.
@azasypkin yes, believe it would be better to update this one after merging #20513
| * /> | ||
| * )} | ||
| * </I18nContext> | ||
| * HOC is used for injecting intl prop into wrapped component |
There was a problem hiding this comment.
nit: same note about HOC vs HOC factory here as well.
💚 Build Succeeded |
LeanidShutau
left a comment
There was a problem hiding this comment.
LGTM. Message syntax is not affected, so no changes are needed to the extraction tool.
…#20542) * add implementation of I18nContext, docs for injectI18n hoc * remove i18nContext wrapper, add docs for react components as classes
|
6.x/6.5: 8f7142f |
#20541