所以我在试用Next.Js 13时,发现redux提供程序有一些奇怪的行为。我看到的不是状态切片,而是一些名为tree、cache、prefetchCache、pushRef、focusAndScrollRef和canonicalUrl的对象。不管怎样,我对Next.JS还是个新手。下面是我的设置:
// client/app/layout.tsx
import React from "react";
import Providers from "./providers";
'use client' // <-- tried with both use client and without
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<Providers>
{children}
</Providers>
</body>
</html>
);
}
// client/app/providers.tsx
'use client'
import React from 'react'
import { Provider } from 'react-redux'
import {store} from '../src/redux/store'
const Providers = ({children}:React.PropsWithChildren) => {
return (
<Provider store={store}>
{children}
</Provider>
)
}
export default Providers
1条答案
按热度按时间wqlqzqxt1#
我遇到了同样的问题,这是一个nextJs bug。您可以在这里找到更多信息:https://github.com/reduxjs/redux-toolkit/issues/3154
在redux工具的标签页中,你会看到“next/router”,在这里你会找到所有的对象,比如树、缓存......如果你选择下一个标签页,你会找到当前的nextjs商店。
确保按如下方式创建存储: