Я учусь reactjs и я получаю сообщение об ошибке при выполнении кода ниже:Реагировать JS Предупреждение: React.createElement:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>React Tutorial</title>
<link rel="stylesheet" href="css/base.css" />
<script type="text/javascript" src="scripts/react-15.0.1.js"></script>
<script type="text/javascript" src="scripts/react-dom.js"></script>
<script type="text/javascript" src="scripts/reactrouter-2.4.1.js"></script>
<script type="text/javascript" src="scripts/babel-core-5.6.16-browser.js"></script>
<script type="text/javascript" src="scripts/jquery-2.2.2.js"></script>
<script type="text/javascript" src="scripts/marked-0.3.5.js"></script>
</head>
<body>
<div id="app20"></div>
<script type="text/javascript" src="scripts/index.js"></script>
<script type="text/babel" src="scripts/example.js"></script>
</body>
</html>
I am using react router to see how the menu works. index.js is classnames js of jedwatson and example.js contains code as below
var Home = React.createClass({
render() {
return (
<div>
<h1>Home...</h1>
</div>
);
}
});'
var About = React.createClass({
render() {
return (
<div>
<h1>About...</h1>
</div>
);
}
});
var Contact = React.createClass({
render() {
return (
<div>
<h1>Contact...</h1>
</div>
);
}
});
var App20 = React.createClass({
render() {
return (
<div>
<ul>
<li><ReactRouter.Link to="/home">Home</ReactRouter.Link></li>
<li><ReactRouter.Link to="/about">About</ReactRouter.Link></li>
<li><ReactRouter.Link to="/contact">Contact</ReactRouter.Link></li>
</ul>
{this.props.children}
</div>
);
}
});
ReactDOM.render((<ReactRouter history = {ReactRouter.browserHistory}>
<ReactRouter.Route path = "/" component = {App20}>
<ReactRouter.IndexRoute component = {Home} />
<ReactRouter.Route path = "home" component = {Home} />
<ReactRouter.Route path = "about" component = {About} />
<ReactRouter.Route path = "contact" component = {Contact} />
</ReactRouter.Route>
</ReactRouter>), document.getElementById('app20'));
Это должно оказать меню с разделами «о», «дом», «контакт », которые отображаются с помощью реализации react-router
. При нажатии на один из пунктов меню соответствующий компонент должен отображаться под меню.
Но я получаю следующее предупреждение ...
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
И эта ошибка ...
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Я был бы признателен, если вы можете помочь мне.
Заранее спасибо.
Возможный дубликат [Что такое NullReferenceException, и как это исправить?] (Http://stackoverflow.com/questions/ 4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – DVK
Возможно, более короткий код будет проще для вас и любого, кто пытается помочь понять проблему более четко? – DannyB