简体   繁体   English

如何在getServerSideProps next js中访问更新的redux store state?

[英]How to access updated redux store state in getServerSideProps next js?

I'm trying to get the latest redux state in getServerSideProps like this:我正在尝试在 getServerSideProps 中获取最新的 redux state,如下所示:

export const getServerSideProps = async (ctx) => {
    const state = store.getState();
    console.log(state.name);

    return { props: { login: false } };
};

But the result I get is the initial name state.但我得到的结果是初始名称 state。

How can I get the latest persisted redux state in getServerSideProps next js?如何在 getServerSideProps next js 中获取最新的持久化 redux state?

I Figured I could only access the latest redux states by only using the latest redux config for next js which is available here:我想我只能通过为下一个 js 使用最新的 redux 配置来访问最新的 redux 状态,该配置可在此处获得:

Next js redux example 下一个 js redux 例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何访问 Next.js 中 getServerSideProps 中的查询参数? - How to access query params inside getServerSideProps in Next.js? Next.js getServerSideProps 加载 state - Next.js getServerSideProps loading state Next.js 如何获取ServerSideProps - Next.js how to getServerSideProps 如何在 Next.js 环境中访问 redux-toolkit 状态(不是初始状态) - how to access redux-toolkit state (not initial state) on Next.js environmemnt 能够从 redux 存储中获取更新的 state 但无法从接收器组件访问更新的 state 中的对象 - Able to get the updated state from redux store but not able to access the objects inside the updated state from the receiver component 如何在下一个 js 中的 getserversideprops 中应用过滤器和分页 - How To apply filters and pagination in getserversideprops in next js 如何使用下一个 js 加速 getServerSideProps? - How to speed up getServerSideProps with next js? React + Redux:商店更新时如何更新状态 - React + Redux: How to update state when store is updated Next.js 在 getServerSideProps 方法中访问 Page props - Next.js access Page props inside the getServerSideProps method 为什么当我尝试在 getServerSideProps 中调度时 State 不会改变? Redux-Next-Wrapper - Why State won't Change When I try to dispatch in getServerSideProps? Redux-Next-Wrapper
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM