I use React Router to navigate to a page in my application as follows:
<Link to={`/single/${this.props.data.pageId}`} params={{singleId: 1}}>GotoPage!</Link>
This works fine, but I would also like to pass an additional property to a new page.
When rendering a component without using a link, I would do something like:
<MyComponent myProp={this.props.data}/>
I tried to skip myProp={this.props.data} in options like this:
<Link to={`/single/${this.props.data.pageId}`} params={{singleId: 1, myProp={this.props.data}}}>GotoPage!</Link>
But it does not work, since myProp undefined on the new page opposes the page to which I can get:
this.props.params.pageId;
Shouldn't I pass non-route parameters using Link ?
source share