I know we can pass value through route by state:
<Link state ={someItem:""}/>
or use useNavigation()
const nav = useNavigation()
const navTo = () =>{
nav("somePage",{state:{someItem:""}}
}
But whenever i try to pass function like
const [state1,setState1] = useState('')
And i pass through state
<Link state ={function:()=>{setState(123)}}/>
It will always return null
{
"pathname": "/search",
"search": "",
"hash": "",
"state": null,
"key": "default"
}
So my question is how to pass function through react-router (V6)
How now to pass value to components?!
<Route exact path='/component' render={() => <myComponent prop={value}/>} />
How to make it that when loading it goes directly to the '/component' page, and not to '/'?!
<Redirect exact from='/' to='/component'/>