withTranslation() Higher-order Component
Learn how to access the translation function or i18n instance inside class components.
We'll cover the following...
We'll cover the following...
What is the withTranslation()
HOC?
The withTranslation()
function will create a higher-order component, which we can pass to the component that is supposed to be translated. The t
and i18n
props will be passed to this component. To do this, we import the function as a named export from the react-i18next
package:
import { withTranslation } from 'react-i18next';
Once imported, we call the function and obtain a higher-order component. We then pass this higher-order ...