EugeneMeles / laravel-react-i18n

Allows to connect your `Laravel` Framework translation files with `React`.
MIT License
75 stars 9 forks source link

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. #2

Closed parth391 closed 1 year ago

parth391 commented 2 years ago

Version: Laravel: 9.29.0 inertiajs/inertia: 0.11.0 inertiajs/inertia-react: 0.8.1

My code(ssr.jsx)

createServer((page) =>
    createInertiaApp({
        page,
        render: ReactDOMServer.renderToString,
        title: (title) => `${title} - ${appName}`,
        resolve(name) {...},
        setup: ({ App, props }) => {
            global.route = (name, params, absolute) =>
                route(name, params, absolute, {
                    ...page.props.ziggy,
                    location: new URL(page.props.ziggy.location),
                });

            return (<LaravelReactI18nProvider
                lang={'en'}
                fallbackLang={'pt'}
                resolve={async (lang) => {
                    const langs = import.meta.globEager('/lang/*.json')
                    return await langs[`/lang/${lang}.json`]()
                }
            }>
                <App {...props} />
            </LaravelReactI18nProvider>);
        },
    })
);

Error

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component.
parth391 commented 2 years ago

@EugeneMeles, can you look at this issue, also?

EugeneMeles commented 1 year ago

Update to latest(2.0.0) version