[英]how can i use Redux in Next js 13
我目前正在將 Next JS 13 與 Redux 一起使用。在 Next.js 12 我可以將我的整個應用程序與Provider
包裝在./pages/_app
中,但是我如何使用 Next JS 13 進行包裝?
下面是我的layout.js
代碼
import "../styles/globals.css";
import BottomBar from "./BottomBar";
import Drawer from "./Drawer";
import Header from "./Header";
import { store } from "../store";
import { Provider } from "react-redux";
export default function RootLayout({ children }) {
return (
<html>
<head />
<body>
<Provider store={store}>
<Header />
<Drawer />
{children}
<BottomBar />
</Provider>
</body>
</html>
);
}
// app/providers.js 'use client'; import { ThemeProvider } from 'acme-theme'; import { AuthProvider } from 'acme-auth'; export function Providers({ children }) { return ( <ThemeProvider> <AuthProvider> {children} </AuthProvider> </ThemeProvider> ); }
import { Providers } from './providers'; export default function RootLayout({ children }) { return ( <html> <body> <Providers>{children}</Providers> </body> </html> ); }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.