我做了一个 looong 研究,但我无法与 next-redux-wrapper、redux-toolkit 和 rtk query 成功集成。
我想在下一个组件中调用 getServerSideProps 来加载用户数据,问题是我实际上无法成功
const ToDoComponent = dynamic(() => import("../components/ToDoComponent"), {
loading: () => <NextNProgress />,
})
const ToDo = () => {
const username = useSelector((state) => state.useReducer.username)
const { isMobileState } = useIsMobile()
//const { data: darkmode} = useGetUserDarkModeQuery(username) /* i want to make those two calls before showing the todoComponent */
//useGetUserListsQuery(username) /* this one tho */
//wanna make those tho queries on getServerSideProps func
setNextTheme(darkmode)
useRedirect()
return (
<>
<ToDoComponent isMobileState={isMobileState} darkmode={darkmode} />
</>
)
}
export async function getServerSideProps() {
store.dispatch(listsApi.endpoints.getUserLists.initiate("hardcoded username"))
//this doesnt work, store is not defined, i try using wrappedStore but the actuall func has an error
}