We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4d9a2c4 + b9cf0d2 commit ef47bb7Copy full SHA for ef47bb7
docs/tips/03-if-else-in-JSX.md
@@ -39,4 +39,25 @@ That's not valid JS. You probably want to make use of a ternary expression:
39
React.renderComponent(<div id={condition ? 'msg' : ''}>Hello World!</div>, mountNode);
40
```
41
42
+If a ternary expression isn't robust enough, you can use `if` statements to determine which
43
+components should be used.
44
+
45
+```js
46
+/** @jsx React.DOM */
47
48
+var loginButton;
49
+if (loggedIn) {
50
+ loginButton = <LogoutButton />;
51
+} else {
52
+ loginButton = <LoginButton />;
53
+}
54
55
+return (
56
+ <nav>
57
+ <Home />
58
+ {loginButton}
59
+ </nav>
60
+)
61
+```
62
63
Try using it today with the [JSX compiler](/react/jsx-compiler.html).
0 commit comments