Reputation: 33715
I successfully followed this guide to learn to use iron-meteor https://medium.com/meteor-js/how-to-build-web-apps-ultra-fast-with-meteor-iron-scaffolding-and-automatic-form-generation-11734eda8e67#.gw50bxjif
So then I went to command line and did a iron add react
.
I created a simple react component app/client/templates/App.jsx
with the contents
App = React.createClass({
render() {
return (
<div className="container">
Hello World
</div>
);
}
});
Then when in app/lib/controllers/issues_list_controller.js
I replaced the action function with this code.
action: function () {
// this.render();
var router = this;
Meteor.startup(function () {
ReactDOM.render(<App router={router} />, document.getElementById("render-target"));
});
},
Now when I run the command iron
from command line to start the project, I get the error
W20151230-00:48:14.955(-5)? (STDERR) ReactDOM.render(<App router={router} />, document.getElementById("render
W20151230-00:48:14.957(-5)? (STDERR) ^
W20151230-00:48:14.980(-5)? (STDERR) SyntaxError: Unexpected token <
It's as if meteor-iron doesn't recognize react and jsx mark up? How do I get this to work?
Upvotes: 0
Views: 121
Reputation: 128
Then when in
app/lib/controllers/issues_list_controller.js
I replaced the action function with this code.
issues_list_controller.js
is a regular javascript file. Rename it with the jsx extension if you want to use JSX in your code - i.e. <App router={router} />
etc.
Upvotes: 0