I am learning reactjs and I am getting errors when executing the code below:
<!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'));
This should render a menu with sections "about", "home", "contact" which are mapped by a react-router
implementation. When clicking on one of the menu items the respective component should be rendered below the menu.
But I am getting the following warning...
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).
And this error...
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
I would appreciate if you are able to help me.
Thanks in advance.