Open Sasha-meow opened 9 months ago
I have the same problem. Or rather, I think it's the same problem.
It seems like you're initialising the store too early, outside of the component, here: https://github.com/Sasha-meow/federation/blob/main/remote/src/component/MainContent/component.tsx#L12
If you move this line into the component body like:
const MainContent = ({ title }: { title: string }) => {
const store = useMemo(() => setupStore(), []);
...
}
it works.
It seems like you're initialising the store too early, outside of the component, here: https://github.com/Sasha-meow/federation/blob/main/remote/src/component/MainContent/component.tsx#L12
If you move this line into the component body like:
const MainContent = ({ title }: { title: string }) => { const store = useMemo(() => setupStore(), []); ... }
it works.
Actually, it didn't help me( Same error But you are right, store must be in component, I updated code
@Sasha-meow same issue, did you find a solution?
Having the same issue using https://lexical.dev/
It seems like you're initialising the store too early, outside of the component, here: https://github.com/Sasha-meow/federation/blob/main/remote/src/component/MainContent/component.tsx#L12 If you move this line into the component body like:
const MainContent = ({ title }: { title: string }) => { const store = useMemo(() => setupStore(), []); ... }
it works.
Actually, it didn't help me( Same error But you are right, store must be in component, I updated code
Did you find a solution?
Versions
Reproduction
npm i
, thennpm run build
andnpm run preview
npm i
andnpm run dev
Steps to reproduce
Button component in remote app includes useGetPokemonsQuery hook (made by redux toolkit). When you start host app - you can see the error:
Uncaught TypeError: Cannot read properties of null (reading 'useMemo')
I tried to install previos versions of your plugin - it didn't help me; tried to change shared dependencies config - it didn't help me too.
If remote app doesn't include rtk query hook, everything works fine (you can delete hook from remote>src>component>ButtonCustom and check it). If replace this hook to native function of the endpoint: everything works fine (you can delete query hook and uncomment dispatch and
const { data } = await dispatch(baseApi.endpoints.getPokemons.initiate(undefined))
on 18 line in remote>src>component>ButtonCustom and check it)