Hi
i´m using createContext, useReducer and build a state managment.
Now i use IonReactRouter IonRouterOutlet and Route.
When i click on a Rout the state is getting lost.
i guess a beginner question
thanks for help
Hi
i´m using createContext, useReducer and build a state managment.
Now i use IonReactRouter IonRouterOutlet and Route.
When i click on a Rout the state is getting lost.
i guess a beginner question
thanks for help
Welcome to the forums!
Without seeing your code, it’s hard to say what the problem is. But depending on what you are doing, you can wrap the context around the router-- if the context is the parent of the router in the tree, then it shouldn’t be possible for the router to mess up the context, because the router exists “below” the context.
For example, I wrap my router with all my contexts like this:
return (
<IonApp>
<PlatformContextProvider>
<LocalizationProvider>
<OfflineContextProvider>
<QueryClientProvider client={queryClient}>
{/* <ReactQueryDevtools /> */}
<ErrorBoundaryRoot>
<ListenersAppRoot>
<MyRouterComponent />
</ListenersAppRoot>
</ErrorBoundaryRoot>
</QueryClientProvider>
</OfflineContextProvider>
</LocalizationProvider>
</PlatformContextProvider>
</IonApp>
);