Next.js Discord

Discord Forum

Provider in main layout did not work

Unanswered
Common carp posted this in #help-forum
Open in Discord
Common carpOP
Can anyone help me explain why there is an error "Cannot access 'handleSignUp' before initialization" while I have defined the action in another file ?
I have two layouts. Main layout in app directory I put Provider for covering every child here. I try to put the Provider in layout of auth directory then the error disappears. That means there are two Providers in my app. But the Providers are the same.

13 Replies

Common carpOP
This is main layout of my app
This is Layout component for checking pathname
I think it’s due to the showToast

Redux store needs the actions, and action needs toast, toast needs redux store.
Because generally, people will store toasts in redux store
so that they can store it globally
@fuma Because generally, people will store toasts in redux store
Common carpOP
Actually, I did not store toasts in redux
I have two 2 actions signin and signup. But there is only an error with signup
No error for sigin
Hmm interesting, try remove showToast calls?
Common carpOP
yeah I have tried but it still has the error
If these actions aren’t referenced anywhere else, I have no idea why it’s happening :animeThink:
The only clue was toast, but now seems it’s not