Reactivity

latest

Reads the freshest in-flight value available inside fn, falling back to the current settled value.


Import

import { latest } from "solid-js";

Type signature

function latest<T>(fn: () => T): T;

Parameters

fn

  • Type: () => T

Expression to read. In-flight values are returned in place of committed ones.


Return value

The value fn returns when in-flight values are read in place of committed ones.


Examples

const preview = () => latest(user);

Caveats

  • Use it on controls, not on content. Data read through latest can show a new answer before the rest of the update agrees with it.
  • Before any value exists, the read still suspends like a normal read.

Common problems


Learn more

Last updated: 9/10/26, 10:47 PMEdit this pageReport an issue with this page