Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
How to Use URL Parameters and Query Strings With React Router

I'm trying to get foo param value from http://localhost:3000/params?foo=123

But I'm getting this error:

Error: Params(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

Why?

import { BrowserRouter as Router, useLocation } from "react-router-dom";

import React from "react";

export function useQuery() {
  return new URLSearchParams(useLocation().search);
}
export function QueryScreen() {
  let query = useQuery();
  return (
    <>
      <h1>{query.get("foo")}</h1>;
    </>
  );
}

export default function Params() {
  <Router>
    <QueryScreen />
  </Router>;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Done! This snippet solved my problem:

import { useRouter } from "next/router";

export default function Items(props) {
  const { query } = useRouter();

  return (
    <div>
      <h1>{query.foo}</h1>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!