@@ -38,7 +38,7 @@ pnpm add @autostorejs/react
3838
3939import { createStore } from ' @autostorejs/react' ;
4040
41- const { $, state,useState } = createStore ({
41+ const { $, state,useReactive } = createStore ({
4242 user: {
4343 firstName: ' zhang' ,
4444 lastName: ' fisher' ,
@@ -50,8 +50,8 @@ const { $, state,useState } = createStore({
5050
5151// use in component
5252const Card = () => {
53- const [ firstName,setFirstName ] = useState (' user.firstName' );
54- const [ lastName,setLastName ] = useState (' user.lastName' );
53+ const [ firstName,setFirstName ] = useReactive (' user.firstName' );
54+ const [ lastName,setLastName ] = useReactive (' user.lastName' );
5555 return <div >
5656 <div >FirstName:{firstName}</div >
5757 <div >LastName:{lastName}</div >
@@ -105,10 +105,7 @@ const Card = () => {
105105
106106` ` `
107107
108- async computed with [loading](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%8A%A0%E8%BD%BD%E7%8A%B6%E6%80%81),[timeout](https://zhangfisher.github.io/autostore/guide/computed-async#%E8%B6%85%E6%97%B6%E5%A4%84%E7%90%86), [retry](https://zhangfisher.github.io/autostore/guide/computed-async#%E9%87%8D%E8%AF%95), [cancel](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%8F%96%E6%B6%88), [countdown](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%80%92%E8%AE%A1%E6%97%B6), [progress](https://zhangfisher.github.io/autostore/guide/computed-async#%E6%89%A7%E8%A1%8C%E8%BF%9B%E5%BA%A6).
109-
110-
111-
108+ async computed with [loading](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%8A%A0%E8%BD%BD%E7%8A%B6%E6%80%81),[timeout](https://zhangfisher.github.io/autostore/guide/computed-async#%E8%B6%85%E6%97%B6%E5%A4%84%E7%90%86), [retry](https://zhangfisher.github.io/autostore/guide/computed-async#%E9%87%8D%E8%AF%95), [cancel](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%8F%96%E6%B6%88), [countdown](https://zhangfisher.github.io/autostore/guide/computed-async#%E5%80%92%E8%AE%A1%E6%97%B6), [progress](https://zhangfisher.github.io/autostore/guide/computed-async#%E6%89%A7%E8%A1%8C%E8%BF%9B%E5%BA%A6).
112109
113110
114111- **Form Two-way Binding**
@@ -118,21 +115,19 @@ Form two-way binding is very simple.
118115` ` ` ts
119116
120117import { createStore ,computed } from ' @autostorejs/react' ;
121-
122- const { $, state,useForm } = createStore ({
123- user: {
124- firstName: ' zhang' ,
125- lastName: ' fisher' ,
126- }
127- });
128-
118+
129119// simple two-way form binding
130120const Card = () => {
131- const user = useForm ()
132- return <div {... user }>
133- <input name = " user.firstName" />
134- <input name = " user.lastName" />
135- </div >
121+ const { Form } = useForm ({
122+ user: {
123+ firstName: ' zhang' ,
124+ lastName: ' fisher' ,
125+ }
126+ })
127+ return <Form >
128+ <input data -field -name = " user.firstName" />
129+ <input data -field -name = " user.lastName" />
130+ </Form >
136131}
137132
138133```
0 commit comments