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

112
Views
Passing props in React Route component for "react-router-dom": "^5.2.0"

I'm using "react-router-dom": "^5.2.0".
I simply want to pass props to Child components Like this
note: this is pseudo-code:

<Route exact path="/databases/buyordersdata" component={BuyOrders param1={value1}} />

This is the React file:


class Databases extends Component {

  render() {
    return (
        <div>
        <BrowserRouter> 
          <Switch> 
            <Route exact path="/databases/" component={Navigation} />
            <Route exact path="/databases/makebuy" component={MakeBuy} />
            <Route exact path="/databases/makesell" component={MakeSell} />
            <Route exact path="/databases/buyordersdata" component={BuyOrders} />
            <Route exact path="/databases/sellordersdata" component={SellOrders} />
            <Route exact path="/databases/AllMyOrders" component={MyOrders} />
          </Switch>     
        </BrowserRouter> 
        </div>
      
      
    )
  }
}

const element = <Databases />;

ReactDOM.render(element, document.getElementById('contents'));

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You just do something like this: Instead of using the route component like that, you can use the Route component as a parent and the component itself as a child.

<Route exact path="/path">
  <BuyOrders param1={value1} /> // Then pass the props like that
</Route>
about 4 years ago · Juan Pablo Isaza Report

0

Solution

In parent component

<Route exact path="/databases/buyordersdata" render={
  (props) => <BuyOrders {...props} order_type={true}/>
}/>

then in Child component

class BuyOrders extends Component {
  constructor(props){
    super(props)

  }
...
render() {
    console.log(this.props.test)
about 4 years ago · Juan Pablo Isaza Report

0

You can easily pass props to a component in the component prop, which should contain JSX format:

<Route exact path="/databases/buyordersdata" component={<BuyOrders param1={value1} />} />
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!