javascript - "ReferenceError: require is not defined", while creating React component using ES6Babel - Stack O

I am trying to create an React ponent using ES6 in JSBin, but I keep on getting the below error. Can so

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 badges
Add a ment  | 

1 Answer 1

Reset to default 9

You 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./.

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信