If
Component for conditional rendering with only if logic (no else clause).
Signature
function If<T>(predicate: () => T, renderIf: (value: T) => Node): Node;Parameters
Returns
Example
const [isAuthenticated, setIsAuthenticated] = createSignal(false);
const [user, setUser] = createSignal({
name: "John Doe",
email: "john.doe@pm.me",
});
const template = If(
isAuthenticated,
(isAuth) => html`<h2>Hi ${user().name}!</h2>`
);Behavior
Advanced Usage
Best Practices
Last updated