Store utilities

unwrap

Edit this page

unwrap removes store proxy wrapping from a store or store subtree.


Import

import { unwrap } from "solid-js/store";

Type

function unwrap<T>(item: T): T;

Parameters

item

  • Type: T

Store value or store subtree to unwrap.


Return value

  • Type: T

Unwrapped value.


Behavior

  • unwrap removes store proxies recursively and returns underlying plain data, reusing existing objects or arrays instead of cloning them when possible.
  • Frozen objects and arrays are shallow-copied before recursive unwrapping, while mutable ones are unwrapped in place.
  • Non-proxy input values are returned unchanged.
  • Mutating the returned value can mutate the underlying store data.

Do not assume unwrap produces an isolated deep clone.


Examples

Basic usage

import { createStore, unwrap } from "solid-js/store";
const [state] = createStore({ user: { name: "John" } });
const user = unwrap(state.user);
user.name = "Jane";

Report an issue with this page