历史丢失函数.装填后推


history.push({
pathname:
vaccineTaken == "Yes" ||
(vaccineTaken == 1 ? "/vaccination" : "/no-vaccine"),
state: data,
onCancel: getExistingSurvey, // This is function
});

属性在重新加载选项卡后被清除,我试图这样做state:{ onCancel: getExistingSurvey}但是它给出了一个错误

这是因为当你重新加载时,你直接调用了路由。而在重新加载之前,它将不具有历史对象。把国家列入历史是一种不好的做法。使用适当的状态管理,如redux或react钩子。

最新更新