valtio

💊 Valtio makes proxy-state simple for React and Vanilla

MIT License

Downloads
1.9M
Stars
8.5K
Committers
84

Bot releases are hidden (Show)

valtio - v1.2.10

Published by dai-shi over 2 years ago

⚠️ ⚠️ ⚠️ 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: https://github.com/pmndrs/valtio/compare/v1.2.9...v1.2.10

valtio - v1.2.9

Published by dai-shi almost 3 years ago

This has small fixes in core, but most notably, it adds a new proxySet util in valtio/utils.

[Important Note] #324 change can be breaking in types if some types are explicitly typed without readonly. See #327 for discussions.

What's Changed

New Contributors

Full Changelog: https://github.com/pmndrs/valtio/compare/v1.2.8...v1.2.9

valtio - v1.2.8

Published by dai-shi almost 3 years ago

This adds unstable_getHandler api which is not documented. It includes some refactorings internally. Please report issues if something goes wrong. Also, this adds UMD and SystemJS builds for CDN.

What's Changed

New Contributors

Full Changelog: https://github.com/pmndrs/valtio/compare/v1.2.7...v1.2.8

valtio - v1.2.7

Published by dai-shi almost 3 years ago

This should improve performance. 🚀

What's Changed

New Contributors

Full Changelog: https://github.com/pmndrs/valtio/compare/v1.2.6...v1.2.7

valtio - v1.2.6

Published by dai-shi almost 3 years ago

Improved devtools util.

What's Changed

Full Changelog: https://github.com/pmndrs/valtio/compare/v1.2.5...v1.2.6

valtio - v1.2.5

Published by dai-shi about 3 years ago

Based on some feedbacks, this version includes some minor fixes.

What's Changed

Full Changelog: https://github.com/pmndrs/valtio/compare/v1.2.4...v1.2.5

valtio - v.1.2.4

Published by dai-shi about 3 years ago

v1.2.3 accidentally requires newer node.js versions. v1.2.4 fixes it by reverting exports format.

  • #247 fix(package): avoid subpath pattern in exports
valtio - v1.2.3

Published by dai-shi about 3 years ago

⚠️ Minimum Node.js requirements (for server-side usage like Next.js): v14.13.0, v12.20.0

This improves devtools in valtio/utils.

  • #223 refactor: stricter tsconfig
  • #232 fix(utils): remove useless internal info in devtools
  • #236 chore(build): simplify exports and support nested subpath
valtio - v1.2.2

Published by dai-shi about 3 years ago

This fixes ESM exports for some environments. Some utils are also improved.

  • #215 fix(utils): fixing subscribeKey typing
  • #221 refactor(core): eliminate any with new useMutableSource emulation
  • #216 fix(build): use .mjs for import condition in exports
  • #227 fix(utils): Adds skipSubscribe option to proxyWithHistory
valtio - v1.2.1

Published by dai-shi about 3 years ago

As reported in #210, there was an issue with ESM build. This version fixes it by updating the dependency.

  • #211 fix: update proxy-compare
valtio - v1.2.0

Published by dai-shi about 3 years ago

We add a new util derive, and deprecate addComputed in favor of it.
In valtio, proxy objects are primitive subscription targets, and derive is a better-fitting abstraction for creating derived / computed values. derive is recommended for both React and Vanilla.

  • #208 refactor(core): useMutableSource emulation without symbol and any
  • #201 feat: derive util
valtio - v1.1.3

Published by dai-shi about 3 years ago

This fixes an issue to handle promises (a.k.a. Suspense) in snapshots.

  • #200 chore(utils): split into files
  • #202 fix: return value in snapshot promise getter after promise is resolved
valtio - v1.1.2

Published by dai-shi about 3 years ago

v1.1.1 has a regression with some bundlers, which is fixed in this version.

  • #197 fix(pkg-exports): .mjs to .js
valtio - v1.1.1

Published by dai-shi about 3 years ago

There were some issues in valtio/utils in v1.1.0, which is fixed in this version. It also improves ESM build to better work with various bundlers.

  • #193 fix(utils): Typescript declaration files for utils
  • #184 fix(build): Hybrid package change for ESM and CJS support
  • #195 fix(utils): proxyWithHistory to undo to initialValue
valtio - v1.1.0

Published by dai-shi about 3 years ago

This version adds a new feature in subscribe. The subscribe callback receives the changes made. This is for expert users who know how valtio behaves internally. There's no docs for the feature (TS types might help).

It has a new util proxyWithHistory based on the new feature. This is for ordinary users.

We encourage 3rd-party library authors to develop some utils based on this new feature.

  • #177 feat: subscribe ops
  • #181 feat: proxyWithHistory
valtio - v1.0.7

Published by dai-shi over 3 years ago

This added "import" export entries for modern bundlers. It might also fix potential bugs in useProxy macro.

  • #169 fix: allow exports type import
valtio - v1.0.6

Published by dai-shi over 3 years ago

This is a maintenance release. It doesn't add any new features or fixes.

  • chore: refactor vanilla.ts and react.ts #163
valtio - v1.0.5

Published by dai-shi over 3 years ago

Add a new util watch and update upstream library.

  • #157 Add watch to valtio/utils
  • #156 chore: update proxy-compare
valtio - v1.0.4

Published by dai-shi over 3 years ago

This adds two improvements.

[BREAKING CHANGE in types] Exported type NonPromise is renamed to DeepResolveType.

  • fix: snapshot typing for ref #146
  • feat: allow import of json to devtools #148
valtio - v1.0.3

Published by dai-shi over 3 years ago

This fixes the "exports" inconsistency issue in build (#140).

Package Rankings
Top 0.81% on Npmjs.org
Top 6.74% on Proxy.golang.org
Top 14.93% on Deno.land
Badges
Extracted from project README
Build Status Build Size Version Downloads Discord Shield
Related Projects