Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to use react hook within cellRenderer is not allowed.

See original GitHub issue

I was trying to use a react-apollo-hook in a custom cellRenderer in order to load data into a modal if the user clicks. However, I get the error message: Invalid hook call: Hooks can only be called inside of the body of a function component.

I believe it is because of the way cellRenderer is being called here.

Is there a different way to accomplish this. Or is using hooks in a cell outside of the scope of this project? Thanks for the help in advance.

For example I was trying to do something like this:

import React from 'react'
import PropTypes from 'prop-types'
import { useLazyQuery } from '@apollo/react-hooks'
import { get } from 'lodash'

import { QUERY } from './queries'

export const InterpretationsCell = ({ cellData,  }) => {

  const [loadDetails, { loading, data }] = useLazyQuery(QUERY) something
  return <p>{cellData}</p>

InterpretationsCell.propTypes = {
  column: PropTypes.shape({
    variantType: PropTypes.string.isRequired,
    idKey: PropTypes.string.isRequired,

export default InterpretationsCell

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

nihgwucommented, Aug 26, 2019

@genomics-geek fixed in v1.7.2

nihgwucommented, Aug 27, 2019

@genomics-geek I’d say that would be problematic if you use local state in cell renderer, as the component will be unmount when it’s out of viewport by scrolling, and all the local state will be lost, from your snippet, I think you can use onRowsRendered to perform lazy data loading, and that’s what we did internally, by that way you can load and cache on demand

Read more comments on GitHub >

github_iconTop Results From Across the Web

react hook useState in AgGridColumn onCellClicked function
Here is the problem: if I want to use my state get/set ( useState hook) inside of the onCellClicked function it is not...
Read more >
Customising React Data Grid with Hooks and Functions
AG Grid supports customisation through components written in React with both classes and hooks. Learn how to use functional hook components.
Read more >
Rules of Hooks - React
Don't call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your React function, before any...
Read more >
Customising Cells with React Components as Cell Renderers
Customising cells using React Cell Renderers, these are simple functions that return JSX to add your own React component to format and add ......
Read more >
ag-Grid Components: Cell Renderers
Use Cell Rendering to have cells rendering values other than simple strings. ... If you do not want to handle the refresh in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found