Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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>
  );
}
Source by reactgo.com #
 
PREVIOUS NEXT
Tagged: #data #mulitple #query #parameters #react
ADD COMMENT
Topic
Name
8+1 =