I am building a React component library which contains some translations, but I want these translations to be provided by the user of my package.
The reason for this is that these translations should be customizable, and I don't want to include every possible language in this package.
So what I'd like to achieve is to use useTranslations
inside my component library like this:
import React from 'react';
import { useTranslation } from 'react-i18next';
const MyComponent = () => {
const { t } = useTranslation();
return <div>{t('helloWorld')}</div>;
};
And somehow the 'helloWorld'
translations should be configurable by the user of the library.
Is there any way to achieve this?
Apparently this was caused by
yarn link
using two versions ofreact-i18next
.To solve this I've configured my app to use the
react-i18next
version of my package:Now my package uses the
i18next
instance configured in my app.