Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
export * from './vanilla'; | ||
export * from './react'; | ||
export { useSnapshot } from './react'; | ||
export { ref, proxy, getVersion, subscribe, snapshot } from './vanilla'; |
@@ -1,2 +0,2 @@ | ||
export * from './vanilla'; | ||
export * from './react'; | ||
export { useSnapshot } from './react'; | ||
export { ref, proxy, getVersion, subscribe, snapshot } from './vanilla'; |
40
index.js
@@ -5,5 +5,5 @@ 'use strict'; | ||
var vanilla = require('valtio/vanilla'); | ||
var react = require('react'); | ||
var proxyCompare = require('proxy-compare'); | ||
var vanilla = require('valtio/vanilla'); | ||
@@ -148,10 +148,32 @@ var TARGET = Symbol(); | ||
Object.defineProperty(exports, 'getVersion', { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla.getVersion; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'proxy', { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla.proxy; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'ref', { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla.ref; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'snapshot', { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla.snapshot; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'subscribe', { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla.subscribe; | ||
} | ||
}); | ||
exports.useSnapshot = useSnapshot; | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { | ||
return vanilla[k]; | ||
} | ||
}); | ||
}); |
@@ -66,2 +66,2 @@ 'use strict'; | ||
exports.default = macro$1; | ||
exports['default'] = macro$1; |
{ | ||
"name": "valtio", | ||
"private": false, | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
"main": "index.js", | ||
"module": "esm/index.js", | ||
"main": "./index.js", | ||
"module": "./esm/index.mjs", | ||
"types": "index.d.ts", | ||
@@ -21,6 +21,7 @@ "typesVersions": { | ||
"./package.json": "./package.json", | ||
"./": "./", | ||
".": { | ||
"types": "./index.d.ts", | ||
"module": "./esm/index.js", | ||
"import": "./esm/index.js", | ||
"module": "./esm/index.mjs", | ||
"import": "./esm/index.mjs", | ||
"default": "./index.js" | ||
@@ -30,4 +31,4 @@ }, | ||
"types": "./vanilla.d.ts", | ||
"module": "./esm/vanilla.js", | ||
"import": "./esm/vanilla.js", | ||
"module": "./esm/vanilla.mjs", | ||
"import": "./esm/vanilla.mjs", | ||
"default": "./vanilla.js" | ||
@@ -37,4 +38,4 @@ }, | ||
"types": "./utils.d.ts", | ||
"module": "./esm/utils.js", | ||
"import": "./esm/utils.js", | ||
"module": "./esm/utils.mjs", | ||
"import": "./esm/utils.mjs", | ||
"default": "./utils.js" | ||
@@ -44,4 +45,4 @@ }, | ||
"types": "./macro.d.ts", | ||
"module": "./esm/macro.js", | ||
"import": "./esm/macro.js", | ||
"module": "./esm/macro.mjs", | ||
"import": "./esm/macro.mjs", | ||
"default": "./macro.js" | ||
@@ -48,0 +49,0 @@ } |
@@ -63,2 +63,23 @@ <img src="logo.svg" alt="valtio"> | ||
<details> | ||
<summary>Use of `this` is for expert users.</summary> | ||
Valtio tries best to handle `this` behavior | ||
but it's hard to understand without familiarity. | ||
```js | ||
const state = proxy({ count: 0, inc() { ++this.count } }) | ||
state.inc() // `this` points to `state` and it works fine | ||
const snap = useSnapshot(state) | ||
snap.inc() // `this` points to `snap` and it doesn't work because snapshot is frozen | ||
``` | ||
To avoid this pitfall, the recommended pattern is not to use `this` and prefer arrow function. | ||
```js | ||
const state = proxy({ count: 0, inc: () => { ++state.count } }) | ||
``` | ||
</details> | ||
#### Subscribe from anywhere | ||
@@ -134,3 +155,3 @@ | ||
See https://github.com/pmndrs/valtio/pull/62 for more information. | ||
See [https://github.com/pmndrs/valtio/issues/61](#61) and [https://github.com/pmndrs/valtio/issues/178](#178) for more information. | ||
@@ -315,5 +336,6 @@ ```js | ||
Valtio is unopinionated about organizing state. | ||
The community is working on best practices on wiki pages. | ||
Valtio is unopinionated about best practices. | ||
The community is working on recipes on wiki pages. | ||
- [How to organize actions](https://github.com/pmndrs/valtio/wiki/How-to-organize-actions) | ||
- [How to persist states](https://github.com/pmndrs/valtio/wiki/How-to-persist-states) |
@@ -1,2 +0,2 @@ | ||
export * from './vanilla'; | ||
export * from './react'; | ||
export { useSnapshot } from './react'; | ||
export { ref, proxy, getVersion, subscribe, snapshot } from './vanilla'; |
@@ -1,2 +0,2 @@ | ||
export * from './vanilla'; | ||
export * from './react'; | ||
export { useSnapshot } from './react'; | ||
export { ref, proxy, getVersion, subscribe, snapshot } from './vanilla'; |
@@ -243,2 +243,3 @@ 'use strict'; | ||
proxyObject.value = proxyObject.history.wip = proxyObject.history.snapshots[--proxyObject.history.index]; | ||
proxyObject.history.snapshots[proxyObject.history.index] = vanilla.snapshot(proxyObject).value; | ||
} | ||
@@ -252,2 +253,3 @@ }, | ||
proxyObject.value = proxyObject.history.wip = proxyObject.history.snapshots[++proxyObject.history.index]; | ||
proxyObject.history.snapshots[proxyObject.history.index] = vanilla.snapshot(proxyObject).value; | ||
} | ||
@@ -261,2 +263,3 @@ }, | ||
}); | ||
proxyObject.saveHistory(); | ||
vanilla.subscribe(proxyObject, function (ops) { | ||
@@ -263,0 +266,0 @@ if (ops.some(function (op) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91281
36
2215
339