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!
In Contact.jsx I have:
const Contacts = ({ contacts, loading }) => { return ( <>{contacts}{loading}> ); }; export default Contacts;
But they are all undefined.
You are passing props to your
component.But you should pass them to your actual
ComponentTry putting the state variable directly into the child element: