Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Pass data between pages react

//Using the <Link /> component:

<Link
  to={{
    pathname: "/page",
    state: data // your data array of objects
  }}
>

//Using history.push()

this.props.history.push({
  pathname: '/page',
    state: data // your data array of objects
})


//Using either of the above options you can now access data on the location
//object as per the below in your page component.

render() {
  const { state } = this.props.location
  return (
    // render logic here
  )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Pass #data #pages #react
ADD COMMENT
Topic
Name
3+2 =