I am trying to send props to component with NavLink.
<NavLink to={{pathname :"/wind", state:{from: "This is my props"}}} >Wind</NavLink>
and I want to get it in this component,
import React from 'react';
import { useLocation} from "react-router-dom"
const Wind = () =>{
const location = useLocation();
const {from} = location.state;
console.log({from})
return (
<div className="Wind">
<h1>Wind</h1>
</div>
);
}
export default Wind;
unfortunatelly this give me result
so I try it like this
import React from 'react';
const Wind = (props) =>{
//console.log(props.location.state)
return (
<div className="Wind">
<h1>Wind</h1>
</div>
);
}
export default Wind;
console log in ths case is undefined. I don´t know why it is not working any ideas?