Next.js with Redux is the framework I am working on, aiming to host the application on Vercel. However, during the local app building process, I'm facing a particular error:
The following error occurs - TypeError: Cannot destructure property 'store' of 'useReduxContext2(...)' as it is null.
Leveraging an if condition can resolve the issue, but unfortunately, using useEffect
like hooks under conditional statements is not viable.
The errors encountered are either:
Error: Cannot destructure property 'store' of 'useReduxContext2(...)' as it is null.
or
Hooks cannot be used conditionally.
The consistent error faced reads as follows:
Error: TypeError: Cannot destructure property 'store' of 'useReduxContext2(...)' as it is null.
This problem arises both locally and on Vercel during the build step. Any alternative solution aside from implementing if conditions?
const STATE = useAppSelector((state: RootState) => state)
if (!STATE) {
return <LoadingPage />
}
const user = useAppSelector((state: RootState) => state.auth);