Skip to content

Unable to set a default layout in React which uses usePage() #1216

Discussion options

You must be logged in to vote

The solution:

  • A persistent layout is not a component, it is an ordinary function which returns JSX - as such, hooks cannot be used in it.
  • The solution is to move usePage() to a new component and return that component from the layout.

Hopefully this will help someone in the future with the same problem.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by finestgecko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant