Skip to content

Commit c87a714

Browse files
committed
feat: use-setState cover object
1 parent 05a868b commit c87a714

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/hooks/src/useSetState/demo/demo.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<vhp-button @click="addTag()">
1313
Add tag
1414
</vhp-button>
15+
16+
<vhp-button @click="cover()">
17+
cover
18+
</vhp-button>
1519
</div>
1620
</template>
1721

@@ -39,6 +43,15 @@
3943
age: 2,
4044
})
4145
}
46+
47+
const cover = () => {
48+
setState(
49+
{
50+
age: 0,
51+
},
52+
true,
53+
)
54+
}
4255
</script>
4356

4457
<style scoped lang="less">

packages/hooks/src/useSetState/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function useSetState<S extends Record<string, any>>(
77
initialState: UseSetStateType<S>,
88
): [
99
DeepReadonly<UnwrapNestedRefs<[S] extends [Ref<any>] ? S : Ref<UnwrapRef<S>>>>,
10-
(patch: Record<string, any>) => void,
10+
(patch: Record<string, any>, cover?: boolean) => void,
1111
] {
1212
const getInitialState = () => unref(initialState)
1313

0 commit comments

Comments
 (0)