Answers for "update URL with react router dom"

5

javascript modify url without reloading page

window.history.pushState('', 'New Page Title', '/new-url.php');
Posted by: Guest on July-22-2019
2

set dynamic route in link react js

<BrowserRouter>
  /* Links */
  {heroes.map(hero => (<Link to={'heroes/' + hero.id} />)}

  /* Component */
  <Route path="heroes/:id" component={Hero} />
</BrowserRouter>

class Hero extends Component {
  render() {
    return (
      <div>
        {this.props.match.params.id}
      </div>
    );
  }
}
Posted by: Guest on May-10-2020

Code answers related to "update URL with react router dom"

Code answers related to "Javascript"

Browse Popular Code Answers by Language