score:0

// In page A
constructor(props) {
  super(props)

  this.state = { number: 0 }
}

setNumber = (num) => {
  this.setstate({
    number: num
  })
}

render() {
  return(
    <PageB {...props} setNumber={() => this.setNumber()} />
  )
}

// In page B
// function where you are calling goBack()

yourFunction() {
  this.props.setNumber(56);
  this.props.history.goBack()
}

render() {
  return(
    <div>{this.props.number}</div>
  )
}

Related Query

More Query from same tag