dijonmusters / build-a-saas-with-next-js-supabase-and-stripe

293 stars 67 forks source link

Invalid hook call in context/users.js #8

Closed SimonApplaunch closed 2 years ago

SimonApplaunch commented 2 years ago

I was trying to follow this guide to make my supabase user globally available in my next.js app but when I attempt to login I'm getting the error "Error: Invalid hook call. Hooks can only be called inside of the body of a function component."

It highlights this line "export const useUser = () => useContext(Context);" as being the cause.

This seems like an issue that everyone who follows this series/tutorial would have as well, though that doesn't seem to be the case? Has something changed recently?

SimonApplaunch commented 2 years ago

Turns out the error message was misleading and it was to do with typescript being unhappy.