我想传递处于组件状态的对象列表。我试图用一个执行类似操作的元素来传递它:
<Link
to={{
pathname: `/contributors/${contributor.id}`,
state: {linkState: this.state.contributors}
}}
>
但是控制台显示错误:
Uncaught DOMException: Failed to execute 'pushState' on 'History': Symbol(react.element) could not be cloned.
这是什么意思以及我能做什么?
最佳答案
@GregBeaver 已经回答了这个问题:https://stackoverflow.com/a/26291578/2079735
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history
...
Looks like the simple answer is that possible the state you are passing in is serializing to larger than 640k
我建议考虑使用 redux
并将值存储到本地状态而不是历史状态中。
关于javascript - React Router v4 - 使用 <Link/> 传递状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45796172/