Last active
March 24, 2017 18:13
-
-
Save StevenJL/6356a7cbd3fa82078f81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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