我一次使用Ag-Grid和React钩子时有错误。我可以解决这个问题吗?我有" gridapi.paginationgotonextpage不是函数"的问题。
const onBtNext = () => {
setTestVar(5);//this is var that defined via react hook, if I not delete this, I will have error
gridApi.paginationGoToNextPage()
console.log(gridApi.paginationGetTotalPages())
}
如果我不使用React Hook,此代码可以完美地工作,但是我在其中
尝试使用REF在功能组件中存储Gridapi如下:
const gridApi = useRef(null);
const onGridReady = params => {
gridApi.current = params.api;
};
const onBtNext = () => {
setTestVar(5);
gridApi.current.paginationGoToNext();
}