Answers for "get data from mulitple query parameters react"

0

get data from mulitple query parameters react

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

export default function Items() {
 //Where parameter url = localhost:3000/items?name=pen&id=12
  const search = useLocation().search;
  const name = new URLSearchParams(search).get('name');  const id = new URLSearchParams(search).get('id');
  return (
    <div>
      <h1>Items page</h1>
      <p>{id}</p>      <p>{name}</p>    </div>
  );
}
Posted by: Guest on September-12-2021

Code answers related to "get data from mulitple query parameters react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language