i use React location library. Want to get token from cookie if it exist then send it to server to check if it is active. My question is how i can do this once before rendering app regardless of route?
i`ve tried something like this but it works only for specific route
{
path: '/',
element: () => import('../pages/Main').then(mod => <mod.default />),
loader: async () => {
return {
user: await fetchResource('user', {}, true)
};
}
},
In App.js you could do something like this