![// Counter.tsrx — hooks next to output, no rules of hooks import { useState, useEffect } from 'octane'; export function Counter(props) @{ const [count, setCount] = useState(0); // A hook behind a condition is fine — slots are // assigned by call site, not call order. if (!props.paused) { useEffect(() => { console.log('count is now', count); }); // the compiler infers [count] } <button onClick={() => setCount(count + 1)}>{'Count: ' + count}</button> }](https://pbs.twimg.com/media/HOPoguXXAAAEnKq.jpg?name=small&format=webp)
ALT // Counter.tsrx — hooks next to output, no rules of hooks import { useState, useEffect } from 'octane'; export function Counter(props) @{ const [count, setCount] = useState(0); // A hook behind a condition is fine — slots are // assigned by call site, not call order. if (!props.paused) { useEffect(() => { console.log('count is now', count); }); // the compiler infers [count] } <button onClick={() => setCount(count + 1)}>{'Count: ' + count}</button> }

ALT A snippet containing the following code: function Price({ items, state }) { const subTotal = calculateSubTotal(items); const tax = calculateTax(subTotal, state); const total = subTotal + tax; return <Text text={total} />; } Price is a react component that takes 2 props, performs some computation and renders a child component called Text.





















