react-node
v1.0.2
Published
Alternative syntax for React
Downloads
447
Readme
react-node
React Node is a lightweight wrapper around React.createElement
with a few extra features.
Installation
$ npm install react-node
Usage
var React = require('react');
var n = require('react-node');
var Link = require('..');
var App = React.createClass({
displayName: 'App',
render: function() {
return (
n('.foo', {
ref: 'foo'
}, [
n(Link, {
onClick: ...
}, 'Bar')
])
);
}
});
Documentation
React Node is smart enough to know when you pass in props, children, both, or none at all. So you don't have to worry about passing in any empty props just to render a component.
n(<tag or component>, <props>, <children>)
n(<tag or component>, <children>)
n(<tag or component>, <props>)
n(<tag or component>)
You can also specify classes and id's on your tags. If you omit the tag, it will default to div
.
n('#bar') // <div id="bar"></div>
n('.foo') // <div class="foo"></div>
n('a.baz') // <a class="baz"></a>
License
MIT