我一直在编码,因为六个月前,我请需要一只手在这方面,我编码这个下一个js 13React应用程序与typescript和我,因为我敲了供应商会话={会话}的redux商店未能创建一个商店为我的切片,只创建一个商店,我相信身份验证和登录这里是我在我的redux商店看到:
\*
y state: {} 6 keys
canonicalUrl: " "
• pushRef: {} 2 keys
• focusAndScrollRef: {} 1 key
• cache: 1) 3 keys
• prefetchCache: (} 3 keys
• tree: {} 5 keys
字符串
这是我的layout.tsx
"use client";
import "bootstrap/dist/css/bootstrap.min.css";
import "styles/globals.scss";
import { ReactNode } from "react";
import Providers from "./Providers";
import { persistStore } from "redux-persist";
import { store } from "redux/store";
import { MyProviders } from "redux/provider";
import { PersistGate } from "redux-persist/integration/react";
import { Session } from "next-auth";
const persistor = persistStore(store);
interface IProps {
children: ReactNode;
session: Session;
}
export default function RootLayout({ children, session }: IProps) {
return (
\<html lang="en"\>
\<body\>
\<MyProviders\>
\<Providers session={session}\>
\<PersistGate persistor={persistor}\>{children} \</PersistGate\>
\</Providers\>
\</MyProviders\>
\</body\>
\</html\>
);
}
型
我相信一切都改变了,因为我通过了会议提供
"use client";
import { SessionProvider } from "next-auth/react";
import React, { ReactNode } from "react";
interface Props {
children: ReactNode;
session: any;
}
function Providers({ children, session }: Props) {
return \<SessionProvider session={session}\>{children}\</SessionProvider\>;
}
export default Providers;
型
这是我的商店,我在开始时创建了一个计数器切片来检查redux是否正常工作,它是
"use client";
import storage from "redux-persist/lib/storage";
import { configureStore, combineReducers } from "@reduxjs/toolkit";
import counterReducer from "./Features/counter/counterSlice";
import { encryptTransform } from "redux-persist-transform-encrypt";
import { persistReducer } from "redux-persist";
const persistConfig = {
key: "root",
storage,
blackList: \[\],
transforms: \[
encryptTransform({
secretKey: process.env.REACT_APP_SECRET_KEY || "nonandrà",
}),
\],
};
const rootReducers = combineReducers({
counter: counterReducer,
});
const persistedReducer = persistReducer(persistConfig, rootReducers);
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =\>
getDefaultMiddleware({
serializableCheck: false,
}),
});
export type RootState = ReturnType\<typeof store.getState\>;
export type AppDispatch = typeof store.dispatch;
型
1条答案
按热度按时间jckbn6z71#
这个问题解决了吗?