2021-03-03 10:00:45 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Initializer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { useEffect, useRef } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-05-27 07:35:43 +02:00
|
|
|
import pluginId from '../../pluginId';
|
|
|
|
import useLocales from '../../hooks/useLocales';
|
2021-03-03 10:00:45 +01:00
|
|
|
|
2021-05-11 12:24:00 +02:00
|
|
|
const Initializer = ({ setPlugin }) => {
|
2021-03-03 10:00:45 +01:00
|
|
|
const { isLoading, locales } = useLocales();
|
|
|
|
const ref = useRef();
|
|
|
|
|
2021-05-11 12:24:00 +02:00
|
|
|
ref.current = setPlugin;
|
2021-03-03 10:00:45 +01:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!isLoading && locales.length > 0) {
|
2021-05-11 12:24:00 +02:00
|
|
|
ref.current(pluginId);
|
2021-03-03 10:00:45 +01:00
|
|
|
}
|
|
|
|
}, [isLoading, locales]);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
Initializer.propTypes = {
|
2021-05-11 12:24:00 +02:00
|
|
|
setPlugin: PropTypes.func.isRequired,
|
2021-03-03 10:00:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Initializer;
|