Skip to content

Instantly share code, notes, and snippets.

@artisonian
Created February 19, 2015 18:52
Show Gist options
  • Save artisonian/b41341f5c64c0821f4b7 to your computer and use it in GitHub Desktop.
Save artisonian/b41341f5c64c0821f4b7 to your computer and use it in GitHub Desktop.
node-jsx example
node_modules
/* jshint node:true */
'use strict';
require('node-jsx').install({
extension: '.jsx',
harmony: true
});
var Test = require('./test');
var test = new Test(); // This was missing from the original
test.testOutput();
require('./es6-component');
var React = require('react');
// `React.createClass` takes in an object...it isn't a class constructor.
// In React v0.13, you can do this instead:
//
// class ES6Component extends React.Component {
// render() {
// return <div>Hello</div>
// }
// }
//
var ES6Component = React.createClass({
render: () => <div>Hello</div> // Note this is an object property
});
{
"name": "node-jsx-example",
"version": "1.0.0",
"description": "Addresses comment in https://github.com/petehunt/node-jsx/issues/26",
"private": true,
"dependencies": {
"node-jsx": "^0.12.4",
"react": "^0.13.0-beta.2"
},
"scripts": {
"start": "node app.js"
}
}
class TestClass {
testOutput() {
console.log('Some text...')
}
}
module.exports = TestClass;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment