I am trying to use CDN to do a simple pivot table using the react-pivottable library.
Here is the HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React PivotTable Example</title>
<!-- React and ReactDOM CDN links -->
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Babel CDN -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!--react-pivottable-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/PlotlyRenderers.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/pivottable.min.css" rel="stylesheet">
</head>
<body>
<div id="root"></div>
<!-- Your React app script -->
<script src="JS/report/ReactPivotTest.js" type="text/babel"></script>
</body>
</html>
and here is the react code:
const e = React.createElement;
const data = [['attribute', 'attribute2'], ['value1', 'value2']];
class ReactPivotTest extends React.Component {
constructor(props) {
super(props);
this.state = props;
}
render() {
return (
<PivotTableUI
data={data}
onChange={s => this.setState(s)}
{...this.state}
/>
);
}
}
const domContainer = document.querySelector('#root');
const root = ReactDOM.createRoot(domContainer);
root.render(e(ReactPivotTest));
When the page loads up I get:
Uncaught ReferenceError: PivotTableUI is not defined
The example is from the CDN site:
text