Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active March 24, 2017 18:13
Show Gist options
  • Save StevenJL/6356a7cbd3fa82078f81 to your computer and use it in GitHub Desktop.
Save StevenJL/6356a7cbd3fa82078f81 to your computer and use it in GitHub Desktop.
// plain javascript
var Form = React.createClass({ ... });
Form.Row = React.createClass({ ... });
Form.Label = React.createClass({ ... });
Form.Input = React.createClass({ ... });
var App = (
React.createElement(Form, null,
React.createElement(Form.Row, null,
React.createElement(Form.Label, null),
React.createElement(Form.Input, null))
)
);
// JSX equivalent
var Form = React.createClass({ ... });
Form.Row = React.createClass({ ... });
Form.Label = React.createClass({ ... });
Form.Input = React.createClass({ ... });
// It looks like the html you're rendering
var App = (
<Form>
<Form.Row>
<Form.Label />
<Form.Input />
</Form.Row>
</Form>
);
// Interpolation is done using { and }
// you can interpolate basic variables
var name = "monkeyman"
var person = <Person name={name} />;
// you can interpolate javascript expressions
var person = <Person name={window.isLoggedIn ? window.name : ''} />;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment