How to customize how to transfer data to < Route/ > in react-router-dom

how do I pass data between components using the < Route/ > tag of react-router-dom ? (without using state machines such as redux)

data can be transmitted in this way when it is normal between the two components

getDataFromSub = (data) =>{
    // 
    console.log(data)
}

<div>
    
    <div>
        <SubComponent setDataToParent={this.getDataFromSub}/>
    </div>
</div>
state={
    data:[
        {id:1,value:"aaa"},
        {id:2,value:"bbb"},
        {id:3,value:"ccc"},
    ]
}

//
this.props.setDataToParent(this.state.data)

<div>
    
</div>

but you can"t pass data like this after using the Route tag

<div>
    
    <div>
        //  
        <Route path={"/get_data"} component={SubComponent} setDataToParent={this.getDataFromSub} />
    </div>
</div>
Dec.30,2021

  1. Url parameters : define a route in the form of /: id . You can use match.params.id to get
  2. .
  3. Query parameters : add parameters to the route, such as / account?name=netflix , and get it yourself
  4. history.push (path, [state]) : push the second parameter can be transferred to any object, and it should be taken out in location.state
  5. .

you can use the query state method of router to pass parameters. It is important to note that query state will be lost after browser refresh

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea8522-1ec8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea8522-1ec8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?