I posted this on discussions earlier but I figured it would be better to ask here for support.
Here is the code I am using in my main file:
const [loaded, setLoaded] = createSignal(false);
const RR: Component<ParentProps> = ({ children }) => (<RestrictedRoute loaded={loaded()}>{children}</RestrictedRoute>);
Here is the code in my RestrictedRoute component:
const RestrictedRoute: Component<ParentProps<{ loaded: boolean }>> = ({ loaded, children }) => {
if (!cookie.get('token')) loaded = true;
if (!loaded) return <Loader/>;
if (loaded && !store.user) return <Navigate href={'/'}/>;
return children;
};
When the component RestrictedRoute is first mounted, the loaded signal is false in the parent component. But once the parent component updates the signal 'loaded' to be true, RestrictedRoute does not update and render the children. It still shows the loader as if the signal is still set to false.
I am pretty new to SolidJS so any help would be appreciated, thanks.