I'm new with React and I want to move an object data from one child component to another, this is my code:
import React from "react";
import SiteRow from "./SiteRow";
import AlertList from "../Alerts/AlertList";
import data from "../../static/fixtures/data.json";
const SiteList = () => {
return (
<div className="row">
<div className="col-8">
<table className="table table-bordered">
<thead>
<tr>
<th scope="col">Site</th>
<th scope="col">Alerts</th>
<th scope="col">Savings</th>
<th scope="col">Uptime</th>
<th scope="col">Power</th>
</tr>
</thead>
<SiteRow sites={data.sites} />
</table>
</div>
<AlertList />
</div>
);
};
export default SiteList;
When I click in a row in the SiteRow component must show data in a child component AlertRow from AlertList, I've been looking for this but I'm stuck, any idea?
Thanks.
I was reading about React Context, but I don't got the idea for sharing the data.