You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Type is not required if it should be inferred from the default value
60
-
const [note, setNote] =useObject<NoteType>({
60
+
const [note, actions] =useObject<NoteType>({
61
61
title: '',
62
62
content: ''
63
63
})
64
64
65
65
function randomizeNote() {
66
-
setNote.replace({
66
+
actions.setValue({
67
67
title: Math.random().toString(12).split('.')[1],
68
68
content: Math.random().toString(12).split('.')[1]
69
69
})
@@ -74,20 +74,20 @@ function App() {
74
74
<input
75
75
value={note.title}
76
76
onChange={e=> {
77
-
setNote.write({
77
+
actions.setPartialValue({
78
78
title: e.target.value
79
79
})
80
80
}}
81
81
/>
82
82
<input
83
83
value={note.content}
84
84
onChange={e=> {
85
-
setNote.write({
85
+
actions.setPartialValue({
86
86
content: e.target.value
87
87
})
88
88
}}
89
89
/>
90
-
<buttononClick={setNote.reset}>Reset to initial value</button>
90
+
<buttononClick={actions.reset}>Reset to initial value</button>
91
91
<buttononClick={randomizeNote}>Random</button>
92
92
</div>
93
93
)
@@ -107,7 +107,7 @@ This component renders its children after the first render. This can be used as
107
107
Usage
108
108
109
109
```jsx
110
-
import { BrowserOnly } = from'react-kuh'
110
+
import { BrowserOnly } from'react-kuh'
111
111
112
112
exportdefaultfunctionPage(){
113
113
return (
@@ -119,26 +119,4 @@ export default function Page(){
119
119
</div>
120
120
)
121
121
}
122
-
```
123
-
124
-
#### `ClientOnly` (component)
125
-
126
-
This component renders its children as they are passed to it, this component has the `use client` directive at the top so it can be used in Next.js's server components to wrap client-only components as well as server components.
0 commit comments