Skip to content
Docs are being updated, please bear with us.

JSX

Instead of placing logic around elements, you control structure from within elements using directives (attributes with special behaviour) like if:

const Counter = ({ count }) => (
<div>
<button onClick={count++}>{count}</button>
<button if={count > 2} onClick={(count = 0)}>
reset
</button>
</div>
);

And special syntax for nesting and repeating:

const CounterList = (counters) => (
<div>
<Counter.nest props={counters[0]} />
<div>
<Counter.repeat items={counters} />
</div>
</div>
);

But you don’t need to remember all this. JSX elements have a tool tip which reminds you of syntax rules and lists the available directives, which have their own tool tips detailing their usage:

Tool tip on JSX element