[]previous and next page

unwrap

Returns the raw data behind a store.

Returns the raw data behind a store. Reads and writes on the result bypass tracking and notification, so writing to it is a bug; use it for identity checks and passing data on.

Import#

ts
import { unwrap } from "@shadow-js/core";

Signature#

ts
function unwrap<T>(store: Store<T>): Mutable<T>

Parameters#

Name Description
store A store view. A value that is not a store view is returned as is.

Returns#

The underlying object, without proxies. It is the live data, not a copy.

Examples#

ts
import { unwrap, useStore } from "@shadow-js/core";

const initial = { items: [1, 2, 3] };
const [list] = useStore(initial);
console.log(unwrap(list) === initial); // true: the store wraps its data in place