mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
Update syntax.md
Some inconsistencies pointed out in FB comments
(cherry picked from commit b6451be582)
This commit is contained in:
parent
5cdc55664d
commit
f7c56d77df
|
|
@ -37,7 +37,7 @@ var Nav;
|
|||
// Input (JSX):
|
||||
var app = <Nav color="blue" />;
|
||||
// Output (JS):
|
||||
var app = Nav({color:'blue'});
|
||||
var app = Nav({color:'blue'}, null);
|
||||
```
|
||||
|
||||
Notice that in order to use `<Nav />`, the `Nav` variable must be in scope.
|
||||
|
|
@ -49,7 +49,7 @@ var Nav, Profile;
|
|||
// Input (JSX):
|
||||
var app = <Nav color="blue"><Profile>click</Profile></Nav>;
|
||||
// Output (JS):
|
||||
var app = Nav({color:'blue'}, Profile({}, 'click'));
|
||||
var app = Nav({color:'blue'}, Profile(null, 'click'));
|
||||
```
|
||||
|
||||
Use the [JSX Compiler](/react/jsx-compiler.html) to try out JSX and see how it
|
||||
|
|
@ -114,7 +114,7 @@ var Nav;
|
|||
// Input (JSX):
|
||||
var tree = <Nav><span /></Nav>;
|
||||
// Output (JS):
|
||||
var tree = Nav({}, React.DOM.span({}));
|
||||
var tree = Nav(null, React.DOM.span(null, null));
|
||||
```
|
||||
|
||||
> Remember:
|
||||
|
|
@ -145,7 +145,7 @@ Likewise, JavaScript expressions may be used to express children:
|
|||
// Input (JSX):
|
||||
var content = <Container>{window.isLoggedIn ? <Nav /> : <Login />}</Container>;
|
||||
// Output (JS):
|
||||
var content = Container({}, window.isLoggedIn ? <Nav /> : <Login />);
|
||||
var content = Container(null, window.isLoggedIn ? Nav(null, null) : Login(null, null));
|
||||
```
|
||||
|
||||
## Tooling
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user