I am trying to create an React ponent using ES6 in JSBin, but I keep on getting the below error. Can someone explain these?
JSBin Error: "ReferenceError: require is not defined at mudaza.js:17:14"
I am trying to create an React ponent using ES6 in JSBin, but I keep on getting the below error. Can someone explain these?
JSBin Error: "ReferenceError: require is not defined at mudaza.js:17:14"
Share Improve this question asked Mar 8, 2016 at 15:23 Aditya SinghAditya Singh 16.7k15 gold badges48 silver badges69 bronze badges1 Answer
Reset to default 9You cannot use imports or requires in JSBin. You need the bundled .js files of the libraries you want to use in your app in the head
of your html file and then use a slightly different syntax to access the ponents or functions from the added libraries.
For example, to use react-router
in a pen, you should add it in the head
of the HTML page hosting your app:
<script src="https://cdnjs.cloudflare./ajax/libs/react-router/2.0.0/ReactRouter.min.js"></script>
Afterwards, in your app's source:
var { Router, Route, IndexRoute, hashHistory, Link } = ReactRouter;
instead of
import { Router, Route, IndexRoute, hashHistory, Link } from "react-router";
I've cloned and updated your JSBin with these changes.
A very good source for most modules .js files is https://cdnjs./.