Solve the problem of getting undefined in React routing attributes
P粉696891871
P粉696891871 2023-08-14 14:56:23
0
2
493

I want to send some properties (loading and getContacts) to a component in ReactJS. I'm using routing to get each path, but the result is undefined in the target component. How is this going?

const App = () => { const [getContacts, setContacts] = useState([]); const [loading, setLoading] = useState(false); return( 
}/> } /> }/> }/> }/> Not Found!
} />
); export default App;

In Contact.jsx I have:

const Contacts = ({ contacts, loading }) => { return ( <> 
{contacts}
{loading}
); }; export default Contacts;

But they are all undefined.

P粉696891871
P粉696891871

reply all (2)
P粉806834059

You are passing props to yourcomponent.

} />

But you should pass them to your actualComponent

} />
    P粉852578075

    Try putting the state variable directly into the child element:

    } />
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!