Being all new in the exciting world of ReactJs, I'm struggling to build the following table component from my data.
I've already set up an api endpoint for it at:
http://domain.com/api/sales/{period-unit}/{period}/{products}
eg. http://domain.com/api/sales/day/1/1,2,3
Which would return the following json (for day 1):
[
{
"productId": 1,
"productSalesCount": 4
},
{
"productId": 2,
"productSalesCount": 65
},
{
"productId": 3,
"productSalesCount": 56
}
]
In jquery I can fetch all the data from all days if I make a GET request for each day like this:
var count = 365 // days in a year
for (var i = 0; i < count; i++) {
$.ajax('http://domain.com/api/sales/day/' + i + "/products/1,2,3"), {});
}
While I could of course find some rather ugly way of building this table in .js and injecting it into the DOM using jquery and .append, I would love to know how to build a reusable table component like this in ReactJs (ideally JSX) - but the form of my data vs the table layout makes it a little hard.
Any genius here who can figure out how to build a table like this, the right way (ideally with React and JSX?)?
