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

88
Views
Rendering query string variables in React

I'm trying to display a query string in my React component.

http://localhost:3000/results?s=hello

Does anyone know why this isn't working?

function Results() {
    var query = new URLSearchParams(this.props.location.search);
    var greeting = query.get('s')
    
    return (
        <div>{greeting}</div>
    )

}

export default Results;

When I replace it with the following it works, but I don't want to hardcode the greeting.

function Results() {
    var greeting = 'Hello'
    
    return (
        <div>{greeting}</div>
    )

}

export default Results;

Thank you

about 4 years ago · Juan Pablo Isaza
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!