Skip to content

Commit e265a08

Browse files
committed
update function name
1 parent 78873d4 commit e265a08

File tree

5 files changed

+45
-39
lines changed

5 files changed

+45
-39
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Simplify communication between React's child components
1515
### Functions link
1616

1717
- [mutateLocalState](#mutatelocalstate)
18-
- [useCreateLocalState](#usecreatelocalstate)
18+
- [useLocalStateCreate](#useLocalStateCreate)
1919
- [useLocalSelector](#uselocalselector)
2020
- [useLocalState](#uselocalstate)
2121

@@ -60,25 +60,25 @@ Write a value to state
6060

6161
___
6262

63-
### useCreateLocalState
63+
### useLocalStateCreate
6464

65-
`Const` **useCreateLocalState**<T\>(`value?`): [LocalState](#localstatet)<T\>
65+
`Const` **useLocalStateCreate**<T\>(`value?`): [LocalState](#localstatet)<T\>
6666

6767
Create a state
6868

69-
#### useCreateLocalState - Type parameters
69+
#### useLocalStateCreate - Type parameters
7070

7171
| Name | Description |
7272
| :--- | :--------------------------------- |
7373
| `T` | The type of value to use for state |
7474

75-
#### useCreateLocalState - Parameters
75+
#### useLocalStateCreate - Parameters
7676

7777
| Name | Type | Description |
7878
| :------- | :--------------- | :------------ |
7979
| `value?` | `T` \| () => `T` | Initial value |
8080

81-
#### useCreateLocalState - Returns
81+
#### useLocalStateCreate - Returns
8282

8383
[LocalState](#localstatet)<T\>
8484

@@ -175,7 +175,7 @@ ___
175175
```tsx
176176
import React from 'react';
177177
import {
178-
useCreateLocalState,
178+
useLocalStateCreate,
179179
LocalState,
180180
useLocalState,
181181
mutateLocalState,
@@ -213,7 +213,7 @@ const Component3 = ({ localState }: { localState: LocalState<number> }) => {
213213
);
214214
};
215215
const App = () => {
216-
const localState = useCreateLocalState(0);
216+
const localState = useLocalStateCreate(0);
217217
console.log('Parent');
218218
return (
219219
<>
@@ -235,7 +235,7 @@ export default App;
235235
```tsx
236236
import React, { VFC } from 'react';
237237
import {
238-
useCreateLocalState,
238+
useLocalStateCreate,
239239
LocalState,
240240
useLocalState,
241241
mutateLocalState,
@@ -294,7 +294,7 @@ export const Bmi: VFC<ChildProps> = ({ localState }) => {
294294
};
295295

296296
const App = () => {
297-
const localState = useCreateLocalState<LocalStateType>({ tall: 170, weight: 60 });
297+
const localState = useLocalStateCreate<LocalStateType>({ tall: 170, weight: 60 });
298298
console.log('Parent');
299299
return (
300300
<>
@@ -318,7 +318,7 @@ import React, { VFC } from 'react';
318318
import {
319319
LocalState,
320320
useLocalSelector,
321-
useCreateLocalState,
321+
useLocalStateCreate,
322322
useLocallReducer,
323323
} from '@react-libraries/use-local-state';
324324

@@ -388,7 +388,7 @@ export const Bmi: VFC<ChildProps> = ({ state }) => {
388388
};
389389

390390
const App = () => {
391-
const state = useCreateLocalState<LocalStateType>(() => ({ tall: 170, weight: 60 }));
391+
const state = useLocalStateCreate<LocalStateType>(() => ({ tall: 170, weight: 60 }));
392392
console.log('Parent');
393393
return (
394394
<>

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@react-libraries/use-local-state",
33
"description": "Simplify communication between React's child components",
4-
"version": "1.0.10",
4+
"version": "1.0.11",
55
"main": "dist/index.js",
66
"license": "MIT",
77
"scripts": {
@@ -27,20 +27,20 @@
2727
},
2828
"devDependencies": {
2929
"@types/jest": "^26.0.23",
30-
"@types/node": "^15.12.2",
30+
"@types/node": "^15.12.4",
3131
"@types/react": "^17.0.11",
32-
"@types/react-dom": "^17.0.7",
32+
"@types/react-dom": "^17.0.8",
3333
"@types/react-test-renderer": "^17.0.1",
3434
"@typescript-eslint/eslint-plugin": "^4.27.0",
3535
"@typescript-eslint/parser": "^4.27.0",
3636
"babel-jest": "^27.0.2",
37-
"eslint": "^7.28.0",
37+
"eslint": "^7.29.0",
3838
"eslint-config-prettier": "^8.3.0",
3939
"eslint-plugin-prettier": "^3.4.0",
4040
"jest": "^27.0.4",
4141
"prettier": "^2.3.1",
4242
"ts-jest": "^27.0.3",
43-
"typescript": "^4.3.2"
43+
"typescript": "^4.3.4"
4444
},
4545
"repository": {
4646
"type": "git",

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface LocalState<T> {
2121
* @param {(T | (() => T))} value Initial value
2222
* @return Instances of state
2323
*/
24-
export const useCreateLocalState: {
24+
export const useLocalStateCreate: {
2525
<T>(value: T | (() => T)): LocalState<T>;
2626
<T = undefined>(value?: T): LocalState<T>;
2727
} = <T>(value: T | (() => T)) => {
@@ -30,6 +30,7 @@ export const useCreateLocalState: {
3030
value: typeof value === 'function' ? (<() => T>value)() : value,
3131
}).current;
3232
};
33+
export const useCreateLocalState = useLocalStateCreate;
3334

3435
/**
3536
* Perform the same action as useState

test/index.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
33
import { act } from 'react-dom/test-utils';
44
import {
55
useLocalState,
6-
useCreateLocalState,
6+
useLocalStateCreate,
77
LocalState,
88
useLocalSelector,
99
useLocallReducer,
@@ -35,7 +35,7 @@ it('initData-undefined', () => {
3535
return <>{value ?? 'undefined'}</>;
3636
};
3737
const Parent = () => {
38-
const localState = useCreateLocalState();
38+
const localState = useLocalStateCreate();
3939
return (
4040
<>
4141
<Component01 localState={localState} />
@@ -64,7 +64,7 @@ it('initData-normal', () => {
6464
return <>{value ?? 'undefined'}</>;
6565
};
6666
const Parent = () => {
67-
const localState = useCreateLocalState(100);
67+
const localState = useLocalStateCreate(100);
6868
return (
6969
<>
7070
<Component01 localState={localState} />
@@ -101,7 +101,7 @@ it('useEffect', () => {
101101
};
102102

103103
const Parent = () => {
104-
const localState = useCreateLocalState<number | string>(100);
104+
const localState = useLocalStateCreate<number | string>(100);
105105
return (
106106
<>
107107
<Component01 localState={localState} />
@@ -141,7 +141,7 @@ it('add', () => {
141141
};
142142

143143
const Parent = () => {
144-
const localState = useCreateLocalState<number>(100);
144+
const localState = useLocalStateCreate<number>(100);
145145
return (
146146
<>
147147
<Component01 localState={localState} />
@@ -182,7 +182,7 @@ it('selector', () => {
182182
};
183183

184184
const Parent = () => {
185-
const localState = useCreateLocalState<LocalStateType>({ value1: 10, value2: 20 });
185+
const localState = useLocalStateCreate<LocalStateType>({ value1: 10, value2: 20 });
186186
return (
187187
<>
188188
<Component01 localState={localState} />
@@ -222,7 +222,7 @@ it('init-function', () => {
222222
};
223223

224224
const Parent = () => {
225-
const localState = useCreateLocalState<number>(() => 100);
225+
const localState = useLocalStateCreate<number>(() => 100);
226226
return (
227227
<>
228228
<Component01 localState={localState} />
@@ -269,7 +269,7 @@ it('reducer', () => {
269269
};
270270

271271
const Parent = () => {
272-
const localState = useCreateLocalState<number>(100);
272+
const localState = useLocalStateCreate<number>(100);
273273
return (
274274
<>
275275
<Component01 localState={localState} />

yarn.lock

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,16 @@
632632
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
633633
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
634634

635-
"@types/node@*", "@types/node@^15.12.2":
635+
"@types/node@*":
636636
version "15.12.2"
637637
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.2.tgz#1f2b42c4be7156ff4a6f914b2fb03d05fa84e38d"
638638
integrity sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==
639639

640+
"@types/node@^15.12.4":
641+
version "15.12.4"
642+
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.4.tgz#e1cf817d70a1e118e81922c4ff6683ce9d422e26"
643+
integrity sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA==
644+
640645
"@types/prettier@^2.1.5":
641646
version "2.3.0"
642647
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.3.0.tgz#2e8332cc7363f887d32ec5496b207d26ba8052bb"
@@ -647,10 +652,10 @@
647652
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
648653
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
649654

650-
"@types/react-dom@^17.0.7":
651-
version "17.0.7"
652-
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.7.tgz#b8ee15ead9e5d6c2c858b44949fdf2ebe5212232"
653-
integrity sha512-Wd5xvZRlccOrCTej8jZkoFZuZRKHzanDDv1xglI33oBNFMWrqOSzrvWFw7ngSiZjrpJAzPKFtX7JvuXpkNmQHA==
655+
"@types/react-dom@^17.0.8":
656+
version "17.0.8"
657+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.8.tgz#3180de6d79bf53762001ad854e3ce49f36dd71fc"
658+
integrity sha512-0ohAiJAx1DAUEcY9UopnfwCE9sSMDGnY/oXjWMax6g3RpzmTt2GMyMVAXcbn0mo8XAff0SbQJl2/SBU+hjSZ1A==
654659
dependencies:
655660
"@types/react" "*"
656661

@@ -1336,10 +1341,10 @@ eslint-visitor-keys@^2.0.0:
13361341
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
13371342
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
13381343

1339-
eslint@^7.28.0:
1340-
version "7.28.0"
1341-
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.28.0.tgz#435aa17a0b82c13bb2be9d51408b617e49c1e820"
1342-
integrity sha512-UMfH0VSjP0G4p3EWirscJEQ/cHqnT/iuH6oNZOB94nBjWbMnhGEPxsZm1eyIW0C/9jLI0Fow4W5DXLjEI7mn1g==
1344+
eslint@^7.29.0:
1345+
version "7.29.0"
1346+
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.29.0.tgz#ee2a7648f2e729485e4d0bd6383ec1deabc8b3c0"
1347+
integrity sha512-82G/JToB9qIy/ArBzIWG9xvvwL3R86AlCjtGw+A29OMZDqhTybz/MByORSukGxeI+YPCR4coYyITKk8BFH9nDA==
13431348
dependencies:
13441349
"@babel/code-frame" "7.12.11"
13451350
"@eslint/eslintrc" "^0.4.2"
@@ -3106,10 +3111,10 @@ typedarray-to-buffer@^3.1.5:
31063111
dependencies:
31073112
is-typedarray "^1.0.0"
31083113

3109-
typescript@^4.3.2:
3110-
version "4.3.2"
3111-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
3112-
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
3114+
typescript@^4.3.4:
3115+
version "4.3.4"
3116+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
3117+
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==
31133118

31143119
universalify@^0.1.2:
31153120
version "0.1.2"

0 commit comments

Comments
 (0)