Skip to content

Commit 0694e2d

Browse files
committed
fix: useDeleteStoreValue does not take any argument
1 parent c5b6d22 commit 0694e2d

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

example/public/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
</head>
3636

3737
<body>
38-
<noscript>
39-
You need to enable JavaScript to run this app.
40-
</noscript>
38+
<noscript> You need to enable JavaScript to run this app. </noscript>
4139

4240
<div id="root"></div>
4341
</body>

src/react-app-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

src/useStore.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ function useSelector(stateSelectorFn) {
6363
* @param {string} key - The lookup key to find the saved value in the store
6464
* @param {any} [defaultValue] - The value if the value in the store is missing
6565
*
66-
* @returns {[any, (value: any) => Promise<void>, (value: any) => Promise<void>]}
66+
* @returns {[any, (value: any) => void, () => void]}
6767
* @return {array} an array with length 3:<br>
6868
* position 0 - the value of the data in the store.<br>
69-
* position 1 - a function *setValue* to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
70-
* position 2 - a function *deleteValue* to delete the value from the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`
69+
* position 1 - a function *setValue* to modify the data in the store.<br>
70+
* position 2 - a function *deleteValue* to delete the value from the store.<br>
7171
*
7272
* @example
7373
* import {useStore} from 'react-context-hook'
@@ -87,8 +87,8 @@ function useStore(key, defaultValue) {
8787
/**
8888
* Returns a function to set or update a variable in the store. You want to use this hook when you just need to modify the store, not read or delete a value from it.
8989
* @param {string} key - the name of the variable to set in the store
90-
* @returns {(value: any) => Promise<void>}
91-
* @return {Function} - a function to set a variable in the store with the given name When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`
90+
* @returns {(value: any) => void}
91+
* @return {Function} - a function to set a variable in the store with the given name<br>
9292
*
9393
* @example
9494
* import {useSetStoreValue} from 'react-context-hook'
@@ -105,18 +105,18 @@ function useSetStoreValue(key) {
105105
/**
106106
* Returns a function to delete a variable in the store. You want to use this hook when you just need to delete a value in the store, not read or set a value from it.
107107
* @param {string} key - the name of the variable to set in the store
108-
* @returns {(value: any) => Promise<void>}
109-
* @return {Function} - a function to delete a variable in the store with the given name. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`
108+
* @returns {(value: any) => void}
109+
* @return {Function} - a function to delete a variable in the store with the given name.
110110
*
111111
* @example
112112
* import {useDeleteStoreValue} from 'react-context-hook'
113113
* const deleteUsername = useDeleteStoreValue('username')
114-
* <button onClick={()=> deleteUsername('my_username')}>set username</button>
114+
* <button onClick={()=> deleteUsername()}>set username</button>
115115
*/
116116
function useDeleteStoreValue(key) {
117117
const { store } = useContext(StoreContext)
118-
return function (value) {
119-
store.dispatch(deleteStoreValueAction(key, value))
118+
return function () {
119+
store.dispatch(deleteStoreValueAction(key))
120120
}
121121
}
122122

@@ -125,10 +125,10 @@ function useDeleteStoreValue(key) {
125125
* `const [value, setValue] = useGetAndSet('a_lookup_key_in_the_store')`. The name of the variable in the arry is arbitrary and you can choose any string you like.
126126
* @param {string} key - The lookup key to find the saved value in the store
127127
* @param {any} [defaultValue] - The default value if missing
128-
* @returns {[any, (value: any) => Promise<void>]}
128+
* @returns {[any, (value: any) => void]}
129129
* @return {array} an array with length 2:<br>
130130
* position 0 - the value of the data in the store.<br>
131-
* position 1 - a function *setValue* to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
131+
* position 1 - a function *setValue* to modify the data in the store.<br>
132132
*
133133
* @example
134134
* import {useGetAndSet} from 'react-context-hook'
@@ -148,10 +148,10 @@ function useGetAndSet(key, defaultValue) {
148148
* `const [value, deleteValue] = useGetAndDelete('a_lookup_key_in_the_store')`. The name of the variable in the arry is arbitrary and you can choose any string you like.
149149
* @param {string} key - The lookup key to find the saved value in the store
150150
*
151-
* @returns {[any, (value: any) => Promise<void>]}
151+
* @returns {[any, (value: any) => void]}
152152
* @return {array} an array with length 2:<br>
153153
* position 0 - the value of the data in the store.<br>
154-
* position 1 - a function *deleteValue* to delete the data in the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`<br>
154+
* position 1 - a function *deleteValue* to delete the data in the store.<br>
155155
*
156156
* @example
157157
* import {useGetAndDelete} from 'react-context-hook'
@@ -169,10 +169,10 @@ function useGetAndDelete(key) {
169169
* `const [setValue, deleteValue] = useGetAndDelete('a_lookup_key_in_the_store')`. The name of the variable in the arry is arbitrary and you can choose any string you like.
170170
* @param {string} key - The lookup key to find the saved value in the store
171171
*
172-
* @returns {[(value: any) => Promise<void>, (value: any) => Promise<void>]}
172+
* @returns {[(value: any) => void, () => void]}
173173
* @return {array} an array with length 2:<br>
174-
* position 0 - a function *setValue* to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
175-
* position 1 - a function *deleteValue* to delete the data in the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`<br>
174+
* position 0 - a function *setValue* to modify the data in the store.<br>
175+
* position 1 - a function *deleteValue* to delete the data in the store.<br>
176176
*
177177
* @example
178178
* import {useGetAndDelete} from 'react-context-hook'

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"resolveJsonModule": true,
2323
"isolatedModules": true,
2424
"noEmit": true,
25-
"jsx": "react"
25+
"jsx": "react-jsx",
26+
"noFallthroughCasesInSwitch": true
2627
}
2728
}

0 commit comments

Comments
 (0)