score:3

Accepted answer

The next version of ag-Grid (and ag-grid-react) will have full support & documentation for using hooks within ag-Grid, but for now all you need to know is that you need to wrap your hook with forwardRef and expose expected lifecycle methods (like getValue) with an useImperativeHandle.

export default forwardRef((props, ref) => {
    const inputRef = useRef();
    useImperativeHandle(ref, () => {
        return {
            getValue: () => {
                return inputRef.current.value;
            }
        };
    });
    return <input type="text" ref={inputRef} defaultValue={props.value}/>;
})

This will work fine for Cell Renderers and Cell Editors, but support for Filters etc will only be available in the next version (22.0.0).


Related Query

More Query from same tag