opshot 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ const user = useMutableState({ name: "Ada", age: 36 });
|
|
|
28
28
|
user.age = 37;
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
The state is created once, on the first render. Pass a function to build the properties once as well, exactly as `useState` does:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
const navigation = useMutableState(createNavigation);
|
|
35
|
+
```
|
|
36
|
+
|
|
31
37
|
## Bounded re-renders
|
|
32
38
|
|
|
33
39
|
React re-renders a component and its children when its state changes.
|
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,6 @@ declare function scope<P extends object>(Component: ComponentType<P>, options?:
|
|
|
180
180
|
|
|
181
181
|
declare function useGroup(): Group;
|
|
182
182
|
|
|
183
|
-
declare function useMutableState<T extends object>(properties: T, group?: Group): T;
|
|
183
|
+
declare function useMutableState<T extends object>(properties: (() => T) | T, group?: Group): T;
|
|
184
184
|
|
|
185
185
|
export { type AddOperation, type Channel, type Context, type Group, type GroupListener, type Ignored, type Op, type Operation, type OperationPath, type RemoveOperation, type ReplaceOperation, type ScopeOptions, type StateListener, TrackedDate, TrackedMap, TrackedSet, type UnsafeTracked, applyOps, createChannel, createGroup, createMutableState, diffSnapshots, identify, ignore, isSameIdentity, isState, scope, subscribe, transact, unsafeTrack, useGroup, useMutableState };
|
package/dist/index.js
CHANGED
|
@@ -2336,7 +2336,7 @@ function useGroup() {
|
|
|
2336
2336
|
}
|
|
2337
2337
|
function useMutableState(properties, group) {
|
|
2338
2338
|
const [{ proxy: proxy2, boundary }] = useState(() => ({
|
|
2339
|
-
proxy: createMutableState(properties, group),
|
|
2339
|
+
proxy: createMutableState(typeof properties === "function" ? properties() : properties, group),
|
|
2340
2340
|
boundary: createBoundary()
|
|
2341
2341
|
}));
|
|
2342
2342
|
const [, bump] = useReducer((value) => value + 1, 0);
|
package/package.json
CHANGED