【发布时间】:2020-11-04 20:45:27
【问题描述】:
所以我是 nextjs 的新手,我无法在路由后在新构建的页面上保持调度状态。请问我们如何保持状态。
基本上我有一个侧边栏,我试图保持活动按钮的状态。
我尝试使用 getInitialProps 获取 url 查询和 useEffect 在加载时分发操作,但 redux 存储仍然是空的。
使用效果
useEffect(() => {
var index;
if (product_id === 'lime') index = 0
if(product_id === 'travetine') index = 1
// console.log(entry, index)
entryClickButton({ // the action I am trying to dispatch however its not happening
type: entry,
newEntries: entry === 'new-entries' ? index : undefined,
soldEntries: entry === 'sold-entries' ? index : undefined
})
}, []);
【问题讨论】:
标签: javascript reactjs react-redux next.js server-side-rendering