S
S
Swaer2018-11-19 16:25:55
React
Swaer, 2018-11-19 16:25:55

How to make a Link from a function in react?

finishGames() {

}

In this code, you need to make it so that there is a transition to the page '/finish The
link is easy to do, clicked and went
But it's exactly that there was a transition to the function, I don't know how

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Geralex, 2018-11-19
@Swaer

Something like this

import React, { Сomponent } from 'react'
import { withRouter } from 'react-rouer-dom'

class Game extends Component {
  constructor(props) {
    super(props)
  }
  finishGames = () => {
    this.props.history.push("/finish")
  }
  render() {...}
}

export default withRouter(Game)

R
r_mustang, 2018-11-19
@r_mustang

via history.push("/finish")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question