Skip to content

Commit 72ff8dc

Browse files
authored
Merge pull request #453 from ozcnii/fix/useField-demo
fix: useField usage in demo examples
2 parents 046d49d + 0fc1079 commit 72ff8dc

8 files changed

Lines changed: 15 additions & 32 deletions

File tree

packages/core/src/helpers/createContext/createContext.demo.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ const App = () => {
88
const age = profileContext.useSelect((state) => state.age);
99
const profile = profileContext.useSelect();
1010

11-
const nameField = useField({
12-
initialValue: DEFAULT_PROFILE.name
13-
});
14-
15-
const ageField = useField({
16-
initialValue: DEFAULT_PROFILE.age
17-
});
11+
const nameField = useField(DEFAULT_PROFILE.name);
12+
const ageField = useField(DEFAULT_PROFILE.age);
1813

1914
return (
2015
<div className='rounded-lg p-4'>

packages/core/src/helpers/createEventEmitter/createEventEmitter.demo.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ const AgeFieldInfo = () => {
2626
};
2727

2828
const Demo = () => {
29-
const nameField = useField({
30-
initialValue: DEFAULT_PROFILE.name
31-
});
32-
33-
const ageField = useField({
34-
initialValue: DEFAULT_PROFILE.age
35-
});
29+
const nameField = useField(DEFAULT_PROFILE.name);
30+
const ageField = useField(DEFAULT_PROFILE.age);
3631

3732
return (
3833
<div className='rounded-lg p-4'>

packages/core/src/helpers/createStore/createStore.demo.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ const AgeFieldInfo = () => {
5252
};
5353

5454
const Demo = () => {
55-
const nameField = useField({
56-
initialValue: DEFAULT_PROFILE.name
57-
});
58-
59-
const ageField = useField({
60-
initialValue: DEFAULT_PROFILE.age
61-
});
55+
const nameField = useField(DEFAULT_PROFILE.name);
56+
const ageField = useField(DEFAULT_PROFILE.age);
6257

6358
return (
6459
<div className='rounded-lg p-4'>

packages/core/src/hooks/useMutation/useMutation.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useField, useList, useMutation } from '@siberiacancode/reactuse';
33
const createUser = (name: string) => Promise.resolve({ name });
44

55
const Demo = () => {
6-
const nameField = useField({ initialValue: '' });
6+
const nameField = useField('');
77
const userList = useList([{ name: 'John' }]);
88

99
const createUserMutation = useMutation(createUser);

packages/core/src/hooks/usePaint/usePaint.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useState } from 'react';
55

66
const Demo = () => {
77
const [color, setColor] = useState('#37d2e6');
8-
const radiusInput = useField({ initialValue: '10' });
9-
const opacityInput = useField({ initialValue: '1' });
8+
const radiusInput = useField('10');
9+
const opacityInput = useField('1');
1010

1111
const radius = radiusInput.watch();
1212
const opacity = opacityInput.watch();

packages/core/src/hooks/useSet/useSet.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useField, useSet } from '@siberiacancode/reactuse';
22

33
const Demo = () => {
4-
const scopeInput = useField({ initialValue: '' });
4+
const scopeInput = useField('');
55
const scopes = useSet(['@siberiacancode', '@siberiacancode-tests', '@shared']);
66

77
return (
@@ -21,7 +21,7 @@ const Demo = () => {
2121
</div>
2222

2323
<div className='mt-4 flex gap-2'>
24-
{Array.from(scopes.value).map((scope, index) => (
24+
{Array.from(scopes.value, (scope, index) => (
2525
<div key={index} className='cursor-pointer' onClick={() => scopes.remove(scope)}>
2626
<code>{scope}</code>
2727
</div>

packages/core/src/hooks/useSpeechSynthesis/useSpeechSynthesis.demo.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { useField, useMount, useSpeechSynthesis } from '@siberiacancode/reactuse
22
import { useState } from 'react';
33

44
const Demo = () => {
5-
const textField = useField({
6-
initialValue: 'Hello, everyone! Good morning!'
7-
});
8-
const pitchField = useField({ initialValue: 1 });
9-
const rateField = useField({ initialValue: 1 });
5+
const textField = useField('Hello, everyone! Good morning!');
6+
const pitchField = useField(1);
7+
const rateField = useField(1);
108
const [voices, setVoices] = useState<SpeechSynthesisVoice[]>([]);
119
const [voice, setVoice] = useState<SpeechSynthesisVoice>();
1210

packages/core/src/hooks/useWebSocket/useWebSocket.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface Message {
88
}
99

1010
const Demo = () => {
11-
const messageInput = useField({ initialValue: '' });
11+
const messageInput = useField('');
1212

1313
const [messages, setMessages] = useState<Message[]>([
1414
{ text: 'Connecting to chat...', type: 'server', date: new Date() }

0 commit comments

Comments
 (0)