Skip to content

Commit 87fd2ab

Browse files
committed
⬆️ if-else.md
1 parent 565b681 commit 87fd2ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pages/if-else.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# If Else
22

3-
The easiest way to have a conditional rendering is to use an `if-else` in React in your render method.
3+
The easiest way to have a conditional rendering is to use an `if-else` in React render method.
44

5-
Imagine you don't want to render your component, because it doesn't have the necessary props. For instance, a List component shouldn't render the list when there is no list of items. You can use an if statement to return earlier from the render lifecycle.
5+
Imagine you don't want to render your component, because it doesn't have the necessary props. For instance, a `List` component shouldn't render the list when there is no list of items. You can use an if statement to return earlier from the render lifecycle.
66

7-
```js
7+
```jsx
88
function List({ list }) {
99
if (!list) {
1010
return null
@@ -20,7 +20,7 @@ function List({ list }) {
2020

2121
A component that returns null will render nothing. However, you might want to show a text when a list is empty to give your app user some feedback for a better user experience.
2222

23-
```js
23+
```jsx
2424
function List({ list }) {
2525
if (!list) {
2626
return null

0 commit comments

Comments
 (0)