rvx
Version:
A signal based rendering library
53 lines (40 loc) • 986 B
Markdown
Render [content](../elements.md
=== "JSX"
```jsx
import { Show } from "rvx";
<Show when={someCondition}>
{() => <>Hello World!</>}
</Show>
```
=== "No Build"
```jsx
import { when } from "./rvx.js";
when(someCondition, () => "Hello World!")
```
Truthy condition results are passed to the child callback as the first argument.
=== "JSX"
```jsx
const message = $("Hello World!");
<Show when={message}>
{value => <h1>{value}</h1>}
</Show>
```
=== "No Build"
```jsx
const message = $("Hello World!");
when(message, value => e("h1").append(value))
```
A function to render fallback content can be specified as the `else` property.
=== "JSX"
```jsx
<Show when={message} else={() => <>No message.</>}>
{value => <h1>{value}</h1>}
</Show>
```
=== "No Build"
```jsx
when(message, value => e("h1").append(value), () => "No message.")
```