Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get url parameter in react js

import React from "react";
import { useLocation } from "react-router-dom";

const MyComponent = () => {
  const search = useLocation().search;
const id=new URLSearchParams(search).get("id");
console.log(id);//12345
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #url #parameter #react #js
ADD COMMENT
Topic
Name
2+5 =