Skip to content

v1.2.10

Compare
Choose a tag to compare
@dai-shi dai-shi released this 24 Jan 12:09
· 260 commits to main since this release

鈿狅笍 鈿狅笍 鈿狅笍 v1.2.10 turns out to have some bugs. Please use v1.2.11 instead. The Migration Guide below is still valid.


This adds new proxyMap and fixes derive, both in valtio/utils. The internal DeepResolveType type is deprecated, which might require migration.

Migration Guide (from v1.2.8 and v1.2.9)

In case you need to specify snapshot types, there are two options.

Assert mutable (let's lie)

type State = { foo?: string }
const state = proxy<State>({})

  const snap = useSnapshot(state) as State
  const handleSnap = (s: State) => {
    // ...
  }

as State can be as typeof state.

Wrap types with Readonly<>

type State = { foo?: string }
const state = proxy<State>({})

  const snap = useSnapshot(state)
  const handleSnap = (s: Readonly<State>) => {
    // ...
  }

Readonly<State> can be Readonly<typeof state>

If the state is deeply nested, please define DeepReadonly type util.

type DeepReadonly<T> = {
  readonly [P in keyof T]: DeepReadonly<T[P]>;
}

  const handleSnap = (s: DeepReadonly<State>) => {
    // ...
  }

What's Changed

Full Changelog: v1.2.9...v1.2.10