help refactoring context with useEffect into layout `beforeload`? - TanStack