I need to pass data from a component to other component by
<Link to={{
pathname: `payment/${id}`,
state: {
data: data,
},
const [inputs, setInputs] = useState({
description: "",
startDate: "",
endDate: "",
})
setInputs({
description: inputs.description,
startDate: startDate,
endDate: endDate,
})
<Link to={{
pathname: `/caravan-rezerve/ek-urunler/${id}`,
state: {
data: inputs,
},
}}
On the other component
const { data } = this.props.location;
I'm getting TypeError: props is undefined
CodePudding user response:
This is the documentation to help you use a Link tag for passing the props and how to use it in the component. https://ui.dev/react-router-pass-props-to-link
Do check the link and then try it again. If you still face issues, please do tell.