How to send data from one react component to another react component?
Solution 1:
You need to use useState
hook to maintain a state. Since you have your Navigate
and Order
component in the same Parent App
.
Do like this
import { useState } from "react";
function App(){
const [some, setSome] = useState(null); // Initial some value is null
function getData(data){
setSome(data); // This will update some state value
}
return(
<div>
<Navigate order_data={some}/>
<Service/>
<Order onAdd={getData}/>
<Review />
<Foot />
</div>
);
}
export default App;