user7605119
user7605119

Reputation:

React Router v4 - passing state with <Link />

I want to pass a list of objects which are in the state of a component. I'm trying to pass it with a element doing something likes this:

<Link 
    to={{
        pathname: `/contributors/${contributor.id}`,
        state: {linkState: this.state.contributors}
    }}
>

But console shows an error:

Uncaught DOMException: Failed to execute 'pushState' on 'History': Symbol(react.element) could not be cloned.

What does it mean and what can I do about that?

Upvotes: 3

Views: 1261

Answers (1)

Dan Mason
Dan Mason

Reputation: 2337

This has been answered by @GregBeaver here: 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

I would suggest looking into using redux and storing the value into local state rather than history state.

Upvotes: 5

Related Questions