Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Invalid Hook Call Issue with Export Function

I am struggling with the hooks and how can i pass the value from one component to another. I have a component called table.js from which i am trying to pass the table cell clicked value to Grid.js. The variable is peerData . I am able to print it on console but can't render it in grid, also not able to use the ag grid api call and getting undefined. Can someone please help me, i am very new to javascript world.

Grid.js :

import ..
   
    const { selectedCompany, peerData } = React.useContext(Context);
    
    
    React.useEffect(() => {
      console.log({peerData})
    }, [peerData]);
    
    
    
    console.log('Checking Context..');
    console.log(selectedCompany);
    console.log({'peerdata detail':peerData});
    
    
    const columnDefs = [
      {
        id: 'currency',
        field: 'currency',
        headerName: 'currency',
      },
      {
        id: 'Cash',
        field: 'Cash',
        headerName: 'Cash',
        width : 200,
        resizable : true,
      },
    ];
    
    
    
    const getPeerData = (rows) => {
      let company = rows;
      console.log('Peer Company Name:')
      console.log(company)
      return company;
    };
    
    const gridOptionsPeers = {
      columnDefs : columnDefs,
      rowData : getPeerData(peerData),
      rowSelection : 'multiple'
    };
    
    
    
    export default function PeerDetails(props) {
    
    
      const { selectCompany } = React.useContext(Context);
    
      function onSelectionChanged() {
        console.log({'Printing Peer Grid':gridOptionsPeers})
        var selectedRows = gridOptionsPeers.api.getSelectedRows();
        if (selectedRows.length == 1) {
          const fsymId = selectedRows[0].currency;
          selectCompany(id);
          console.log({'These rows Selected' : id})
        }
        else {
          console.log('No row selected');
        }
      }
      return (
        <Card>
          <CardHeader><h4>Peers</h4>
          </CardHeader>
          <CardBody>
            <Row style={{ height: '450px' }}>
              {/* {  <Col w='' style={{ width: w, minWidth: w, maxWidth: w }}>
                {<PeersChart />}
              </Col>} */}
              <Col>
                <Grid
                  columnDefs={columnDefs}
                  style={{ width: '100%', height: '100%' }}
                  containerStyle={{ width: '100%', height: '100%' }}
                  tooltipShowDelay={0}
                  onSelectionChanged={onSelectionChanged}
                  gridOptions={gridOptionsPeers}
                />
              </Col>
            </Row>
          </CardBody>
        </Card>
      );
    };
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!