Releases: pmndrs/valtio
v1.5.1
v1.5.0
This uses useSyncExternalStore
from React 18. It uses a shim when it's with pre-18, so nothing is breaking.
What's Changed
- fix(utils): avoid infinite loop with mutual derive usage by @dai-shi in #399
- fix(utils/devtools): enabled option and supress warning by @dai-shi in #400
- feat: use-sync-external-store by @dai-shi in #234
- refactor(vanilla): Use the default parameters by @ahaoboy in #405
New Contributors
Full Changelog: v1.4.0...v1.5.0
v1.4.0
This release adds valtio/macro/vite
to enable useProxy
macro for vite users. It's pretty new and may contain bugs. Feel free to report issues.
It also includes various non-trivial bug fixes.
What's Changed
- fix(utils/watch): avoid infinite loop with sync by @dai-shi in #385
- feat(macro): macro for vite by @Aslemammad in #386
- fix(utils): devtools better types by @Aslemammad in #389
- fix: support tracking hasOwnProperty in render optimization by @dai-shi in #393
New Contributors
- @LuckyPigeon made their first contribution in #388
Full Changelog: v1.3.1...v1.4.0
v1.3.1
v1.3.0
This fixes some build issues. UMD/SystemJS builds are completely renewed. Exported functions are refactored for TypeScript and we have an easier option to loosen useSnapshot
typing (#357).
What's Changed
- feat(build): use
__DEV__
to control development mode by @dai-shi in #338 - fix(utils): do not depend on react in build by @dai-shi in #358
- refactor: prefer function declaration by @dai-shi in #359
- breaking(core): drop deprecated types by @dai-shi in #364
Full Changelog: v1.2.12...v1.3.0
v1.2.12
v1.2.11
v1.2.10 has two serious issues: a) TS types for useSnapshot
and proxyWithComputed
are broken. b) derive
has a bug. They should be fixed in v1.2.11, but there can still be some bugs. Please feel free to open issues.
What's Changed
- fix(utils): re-implement derive to make glitch free (#335 was buggy) by @Noitidart in #341
- fix(types): workaround for extracting types by @dai-shi in #342
New Contributors
- @roguesherlock made their first contribution in #339
Full Changelog: v1.2.10...v1.2.11
v1.2.10
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
- feat(utils): add proxyMap by @fkhadra in #330
- fix: avoid const enum and deprecate DeepResolveType by @dai-shi in #333
- fix(utils): make derive glitch free by @dai-shi in #335
Full Changelog: v1.2.9...v1.2.10
v1.2.9
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
- fix(core): improve DeepResolveType type by @JohnnyNomad in #324
- fix(core): expose canProxy in handler by @dai-shi in #321
- feat(utils): add proxy set by @fkhadra in #325
New Contributors
- @JohnnyNomad made their first contribution in #324
- @fkhadra made their first contribution in #325
Full Changelog: v1.2.8...v1.2.9
v1.2.8
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
- fix(build): Generate umd and system files by @romulo94 in #312
- feat(core): expose proxy handler experimentally by @dai-shi in #298
New Contributors
Full Changelog: v1.2.7...v1.2.8