Skip to content

Commit

Permalink
add images
Browse files Browse the repository at this point in the history
  • Loading branch information
dgodinez-dh committed Dec 11, 2024
1 parent a0be754 commit dc0fa84
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions plugins/ui/docs/describing/conditional_rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def packing_list():
my_packing_list = packing_list()
```

![my_packing_list](../_assets/conditional_rendering1.png)

Some of the `item` components have their `is_packed` prop set to `True` instead of `False`. You want to add a checkmark (✅) to packed items if `is_packed=True`.

You can write this as an if/else statement like so:
Expand Down Expand Up @@ -58,6 +60,8 @@ def packing_list():
my_packing_list = packing_list()
```

![my_packing_list2](../_assets/conditional_rendering2.png)

Notice you are creating branching logic with Python's if and return statements. In `deephaven.ui`, control flow (like conditions) is handled by Python.

### Conditionally return nothing with `None`
Expand Down Expand Up @@ -89,6 +93,8 @@ def packing_list():
my_packing_list = packing_list()
```

![my_packing_list3](../_assets/conditional_rendering3.png)

If `is_packed` is True, the component will return nothing. Otherwise, it will return a component to render.

In practice, returning `None` from a component is not common because it might surprise a developer trying to render it. More often, you would conditionally include or exclude the component in the parent component. Here’s how to do that.
Expand Down

0 comments on commit dc0fa84

Please sign in to comment.