Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trying to pass data from a component to other – REACT JS

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading