Reactjs 如何在React中使用AG网格?我得到构建错误

Reactjs 如何在React中使用AG网格?我得到构建错误,reactjs,ag-grid,spfx,Reactjs,Ag Grid,Spfx,以下是组件文件: import { AgGridReact } from '@ag-grid-community/react'; import {AllCommunityModules} from '@ag-grid-community/all-modules'; import '@ag-grid-community/all-modules/dist/styles/ag-grid.css'; import '@ag-grid-community/all-modules/dist/styles/a

以下是组件文件:

import { AgGridReact } from '@ag-grid-community/react';
import {AllCommunityModules} from '@ag-grid-community/all-modules';
import '@ag-grid-community/all-modules/dist/styles/ag-grid.css';
import '@ag-grid-community/all-modules/dist/styles/ag-theme-balham.css';



export default class FormGrid extends React.Component<IFormGridProps,IFormGridState> {
   constructor(props: IFormGridProps, state: IFormGridState){
   super(props);
   this.state = {
     columnDefs: [
      { headerName: "Make", field: "make" },
      { headerName: "Model", field: "model" },
      { headerName: "Price", field: "price" }],
     rowData: [
      { make: "Toyota", model: "Celica", price: 35000 },
      { make: "Ford", model: "Mondeo", price: 32000 },
      { make: "Porsche", model: "Boxter", price: 72000 }]
     }
    }
public render(): React.ReactElement<IFormGridProps> {
return (
  <div className={ styles.formGrid }>
    <div className={ styles.container }>
      <div className={ styles.row }>
      <div className="ag-theme-balham" style={ {height: '200px', width: '600px'} }>
      <AgGridReact
        columnDefs={this.state.columnDefs}
        rowData={this.state.rowData}
        modules={AllCommunityModules}>
      </AgGridReact>
      </div>  
      </div>
    </div>
  </div>
 );
 }
 }

我不明白为什么会出错。请帮帮我

确保已安装“@ag grid community/all modules”软件包 我尝试了你的代码,它编译得很好,但我必须安装上面的软件包。你也可以粘贴你的进口吗

其他注意事项/提示:

  • 在第2行中,您只能将
    props
    作为React类组件的参数传递(但这不会给您带来这样的错误)
  • 不需要为渲染方法添加类型

ag网格模块已安装。我已经在问题中添加了导入,你从哪里获得styles.formGrid和类似的?如果不是这样,那么尝试一步一步地调试。首先确保除``部分之外的所有部分都已编译。所以暂时移除它。然后,如果上面的工作正常,那么将状态变量替换为空数组,如下所示:``
export interface IFormGridState{
   columnDefs: any,
   rowData: any
}