Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs AgGrid在React应用程序中重新渲染时崩溃_Reactjs_Typescript_Ag Grid - Fatal编程技术网

Reactjs AgGrid在React应用程序中重新渲染时崩溃

Reactjs AgGrid在React应用程序中重新渲染时崩溃,reactjs,typescript,ag-grid,Reactjs,Typescript,Ag Grid,我有一个React+Typescript应用程序,它使用AgGrid显示数据。数据从服务器获取,然后反馈给AgGrid,用户可以使用多个选项进行交互,这些选项可能会更改显示的数据,例如过滤器、分页和其他一些自定义内容 首先获取显示的数据,然后完整显示。例如,我们获取25行并显示所有行,我们没有使用AgGrid的任何分页功能 如果用户对其中一个参数进行了更改,而数据没有更改(例如,添加一个捕获已显示的每个项目的筛选器),则将重新获取数据,然后再次将其馈送到AgGrid,但这将导致AgGrid崩溃

我有一个React+Typescript应用程序,它使用AgGrid显示数据。数据从服务器获取,然后反馈给AgGrid,用户可以使用多个选项进行交互,这些选项可能会更改显示的数据,例如过滤器、分页和其他一些自定义内容

首先获取显示的数据,然后完整显示。例如,我们获取25行并显示所有行,我们没有使用AgGrid的任何分页功能

如果用户对其中一个参数进行了更改,而数据没有更改(例如,添加一个捕获已显示的每个项目的筛选器),则将重新获取数据,然后再次将其馈送到AgGrid,但这将导致AgGrid崩溃

只有当数据不变时才会发生这种情况

发生的错误如下:

The above error occurred in the <AgGridReact> component:
    in AgGridReact (at ag-collections/index.tsx:250)
    in div (at ag-collections/index.tsx:240)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (at ag-collections/index.tsx:225)
    in main (at main/index.tsx:59)
    in div (at main/index.tsx:36)
    in Component (created by WithStyles(Component))
    in WithStyles(Component) (at ag-collections/index.tsx:218)
    in TableAg (created by Context.Consumer)
    in Connect(TableAg) (created by Connect(TableAg))
    in Connect(TableAg) (created by Context.Consumer)
    in withRouter(Connect(TableAg)) (created by WithStyles(withRouter(Connect(TableAg))))
    in WithStyles(withRouter(Connect(TableAg))) (created by Context.Consumer)
    in Route (at routes.tsx:20)
    in Switch (at routes.tsx:16)
    in Routes (at app.tsx:50)
    in ThemeProvider (at app.tsx:48)
    in Route (created by QueryParamProvider)
    in QueryParamProvider (at app.tsx:47)
    in Provider (at app.tsx:46)
    in App (at src/index.tsx:8)
    in Router (created by HashRouter)
    in HashRouter (at src/index.tsx:7)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <link removed> to learn more about error boundaries. index.js:1437
TypeError: can't define property "areEquivPropertyTracking": Array is not extensible
changeDetectionService.js:147
TypeError: can't define property "areEquivPropertyTracking": Array is not extensible
据我所知,他们正试图在对象a上创建一个新项目,但这是被禁止的


如果我需要提供任何其他东西,我可以尝试这样做。如何解决此问题?

如果提供的数据是不可变的,那么您将无法执行深入检查,因为这会尝试扩展提供的对象

但是,可以使用多种数据更改检测策略

我通过向AgGridReact组件添加以下内容解决了此问题:

从'ag grid react/lib/changeDetectionService'导入{ChangeDetectionStrategyType}
...
github的回答是@benhodeda,上面说:

你好:) 当我将state对象迁移到使用immer而不是immutableJS时,我遇到了类似的问题。 我们将状态绑定到AgGridReact的rowData prop,当我们过滤数据(服务器端过滤)时,应用程序在执行更改检测时崩溃。我在AgGridReact组件上添加了deltaRowDataMode属性和getRowNodeId={row=>row.id}

您可以在此处阅读更多内容:


您需要提供一个可复制的示例,例如StackBlitz