[Ag-grid] 부모 컴포넌트에서 자식 컴포넌트의 테이블 데이터 가져오기

wishwish·2024년 3월 30일
0

React

목록 보기
5/5
// home.tsx

const gridRef = useRef<GridApi>();

const handleGridReady = (e: GridReadyEvent<Unit>) => {
	gridRef.current = e.api;
};

return <table onGridReady={handleGridReady} />
// table.tsx

<AgGridReact onGridReady={onGridReady}/>

Ag-grid가 준비가 되었을 때 onGridReady 함수를 통해 부모에 테이블의 api를 넘길 수 있다.
onGridReady 옵션은 javascript의 onload 이벤트와 유사하다고 한다.

0개의 댓글