javascript - ag-grid-react crashing on basic component import: missing react-dom-factories - Stack Overflow

When importing a basic ponent I have webpack crash on me. I'm unsure as to why this is happening b

When importing a basic ponent I have webpack crash on me. I'm unsure as to why this is happening but it seems to be a missing lib within the ag-grid-react package... Has anyone run into this before? Any advice would be much obliged!

import Table from './ponents/Table'

When creating the Table ponent it piles ok, but as soon as I import it as above, it crashes webpack.

// Table.js

import React, { Component } from "react";
import { AgGridReact } from "ag-grid-react";

class Table extends Component {
  constructor(props) {
    super(props);

    this.state = {
      columnDefs: this.createColumnDefs(),
      rowData: this.createRowData()
    };
  }

  onGridReady(params) {
    this.gridApi = params.api;
    this.columnApi = params.columnApi;

    this.gridApi.sizeColumnsToFit();
  }

  createColumnDefs() {
    return [
      { headerName: "Make", field: "make" },
      { headerName: "Model", field: "model" },
      { headerName: "Price", field: "price" }
    ];
  }

  createRowData() {
    return [
      { make: "Toyota", model: "Celica", price: 35000 },
      { make: "Ford", model: "Mondeo", price: 32000 },
      { make: "Porsche", model: "Boxter", price: 72000 }
    ];
  }

  render() {
    let containerStyle = {
      height: 115,
      width: 500
    };

    return (
      <div style={containerStyle} className="ag-fresh">
        <h1>Simple ag-Grid React Example</h1>
        <AgGridReact
          // properties
          columnDefs={this.state.columnDefs}
          rowData={this.state.rowData}
          // events
          onGridReady={this.onGridReady}
        />
      </div>
    );
  }
}

export default Table;

When importing a basic ponent I have webpack crash on me. I'm unsure as to why this is happening but it seems to be a missing lib within the ag-grid-react package... Has anyone run into this before? Any advice would be much obliged!

import Table from './ponents/Table'

When creating the Table ponent it piles ok, but as soon as I import it as above, it crashes webpack.

// Table.js

import React, { Component } from "react";
import { AgGridReact } from "ag-grid-react";

class Table extends Component {
  constructor(props) {
    super(props);

    this.state = {
      columnDefs: this.createColumnDefs(),
      rowData: this.createRowData()
    };
  }

  onGridReady(params) {
    this.gridApi = params.api;
    this.columnApi = params.columnApi;

    this.gridApi.sizeColumnsToFit();
  }

  createColumnDefs() {
    return [
      { headerName: "Make", field: "make" },
      { headerName: "Model", field: "model" },
      { headerName: "Price", field: "price" }
    ];
  }

  createRowData() {
    return [
      { make: "Toyota", model: "Celica", price: 35000 },
      { make: "Ford", model: "Mondeo", price: 32000 },
      { make: "Porsche", model: "Boxter", price: 72000 }
    ];
  }

  render() {
    let containerStyle = {
      height: 115,
      width: 500
    };

    return (
      <div style={containerStyle} className="ag-fresh">
        <h1>Simple ag-Grid React Example</h1>
        <AgGridReact
          // properties
          columnDefs={this.state.columnDefs}
          rowData={this.state.rowData}
          // events
          onGridReady={this.onGridReady}
        />
      </div>
    );
  }
}

export default Table;

Webpack crashes with

./node_modules/ag-grid-react/lib/agGridReact.js Module not found: Can't resolve 'react-dom-factories' in '/Users/username/Sites/site/node_modules/ag-grid-react/lib'

Share Improve this question asked Nov 16, 2017 at 10:00 Monty MonroMonty Monro 6132 gold badges10 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

With react-dom 15.5 (I think), react-dom-factories was moved to a separate module. ag-grid-react was updated to account for this and added react-dom-factories as a peer dependency in its package.json. You likely got a warning when installing ag-grid-react about missing the react-dom-factories dependency.

To resolve this, try running npm install react-dom-factories (or the yarn equivalent if you're using yarn).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744723650a4590059.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信