Answers for "use params react"

6

use params

import { useHistory } from "react-router-dom";

function HomeButton() {
  let history = useHistory();

  function handleClick() {
    history.push("/home");
  }

  return (
    <Button type="button" onClick={handleClick}>
      Go home
    </Button>
  );
}
Posted by: Guest on May-11-2020
10

react router url params

import { Route, useParams } from "react-router-dom";

// Route with URL param of id
<Route path="/:id" children={<Child />} />

// We can use the `useParams` hook here to access
// the dynamic pieces of the URL.
let { id } = useParams();
Posted by: Guest on July-20-2020
7

get query params react

new URLSearchParams(this.props.location.search).get("your_query_param_key")
Posted by: Guest on August-31-2020
-1

use query params react

const query = new URLSearchParams(this.props.location.search);

const token = query.get('token')
console.log(token)//123
Posted by: Guest on March-17-2020
0

react router params and render

<Route path="/:id" render={(props) => (<Child {...props} />)} />
Posted by: Guest on October-11-2021
-1

get param is react

const pathArray = window.location.pathname.split('/');
        const id = pathArray[2];
Posted by: Guest on June-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language