I am trying to include PrintGrid functional component in my LoadGridData component. The PrintGrid should receive a document_id of firebase from LoadGridData. But inside the return statement of the LoadGridData, I try to pass the grid_id which is in a grid_data list to PrintGrid and it causes grid_id value to be undefined.
function PrintGrid(grid_id) {
console.log('Print grid_id in PrintGrid: ', grid_id);
The below gives an error that it cannot access index 0 of undefined.
{grid_data && <PrintGrid grid_id={grid_data[0]} />}
With only the following statement, it updates the grid_data[0] value (grid_id) to the webpage.
{grid_data && <p> {grid_data[0]} </p>}
function PrintGriddefinition - the argumentgrid_idshould be enclosed in{ }- i.e.function PrintGrid({ grid_id })(so that thepropsare deconstructed into thegrid_id). However, that should not be causing the other problem. Please provide more code. TheLoadGridDatacode. Also, the connection ofdocument_idto the rest is unclear.