manuelbieh / react-ssr-setup

React Starter Project with Webpack 4, Babel 7, TypeScript, CSS Modules, Server Side Rendering, i18n and some more niceties

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why child components would be rerendered when I18n got texts by XHR ?

zhangyugege opened this issue · comments

Hello~ I am a beginner.

I am studying this great project.

I have a question about some details of this project.

Source code at here: https://github.com/manuelbieh/react-ssr-setup/blob/master/src/shared/i18n/IntlProvider.tsx#L46

import i18nextXHRBackend from 'i18next-xhr-backend';
// ...
const I18N: React.FC<any> = ({ children }) => {
    const locale = useSelector(getLocale);
    useEffect(() => {
        i18next.changeLanguage(locale);
    }, [locale]);

    return <I18nextProvider i18n={i18next}>{children}</I18nextProvider>;
};

My question is why children will rerender when i18nextXHRBackend got texts from backend?
I am trying to create a project by myself without I18nextProvider and redux, and my child component couldn't rerender, and only render once before xhr got texts.:robot::see_no_evil: