react-pivot icon indicating copy to clipboard operation
react-pivot copied to clipboard

"react-pivot/index.jsx" Unexpected token error when using "basic example" from documentation

Open nissan opened this issue 6 years ago • 3 comments

Using the exact syntax of Basic example I get the error when trying to embed this as a React component in a page:

../node_modules/react-pivot/index.jsx
Module parse failed: Unexpected token (120:6)
You may need an appropriate loader to handle this file type.
| 
|     var html = (
|       <div className='reactPivot'>
| 
|       { this.props.hideDimensionFilter ? '' :

My call is simply

import React from "react";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import AddressBookPivotTable from '../components/AddressBookPivotTable';

const Routes = ({ props }) => (
  <Router>
    <AddressBookPivotTable/>
  </Router>
);

export default Routes;

and the underlying component is declared as

class AddressBookPivotTable extends React.Component {
  render() {
    return (
      <ReactPivot
        rows={rows}
        dimensions={dimensions}
        reduce={reduce}
        calculations={calculations}
        activeDimensions={["Transaction Type"]}
        nPaginateRows={25}
      />
    );
  }
}
export default AddressBookPivotTable;

It's a create-react-app generated application this is embedded within. Any help solving this would be appreciated

nissan avatar May 05 '18 02:05 nissan

Does this help? https://github.com/davidguttman/react-pivot/issues/12#issuecomment-163990821

davidguttman avatar May 08 '18 17:05 davidguttman

Check out #47 towards the bottom. Currently this does not work with create-react-app.

kelyndm avatar Jul 26 '18 18:07 kelyndm

Can it work with create-react-app now? Please update. Thanks!

dwy189 avatar Jul 03 '19 22:07 dwy189