I was wondering if it's possible and how to wrap my top level page _app.js
within Redux provider considered I already wrapped it with Next-auth provider like:
import React from "react"
import { Provider } from 'next-auth/client'
import '../public/global.scss'
export default function App ({ Component, pageProps }) {
return (
<Provider
options={{
clientMaxAge: 0,
keepAlive: 5 * 60
}}
session={pageProps.session} >
<Component {...pageProps} />
</Provider>
)
}
The issue is that when I try to add also Reduct <Provider..
it says "Provider" is already defined.
You can rename the redux provider named import using as
.
import React from "react"
import { Provider as NextAuthProvider } from 'next-auth/client'
import { Provider as ReduxProvider } from 'react-redux'
import '../public/global.scss'
export default function App ({ Component, pageProps }) {
return (
<ReduxProvider>
<NextAuthProvider
options={{
clientMaxAge: 0,
keepAlive: 5 * 60
}}
session={pageProps.session} >
<Component {...pageProps} />
</NextAuthProvider>
</ReduxProvider>
)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.