Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/dobPublic

Commit8dacce4

Browse files
committed
update readme
1 parentb7c9cce commit8dacce4

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

‎readme.md‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,43 @@ obj.a = 2 // <· obj.a has changed to 2
3333

3434
You can enjoy the benefits of proxy, for example`obj.a = { b: 5 }` is effective.
3535

36-
##Use in react
36+
##Use in react component
37+
38+
```typescript
39+
import {Action,observable,combineStores,inject }from'dob'
40+
import {Connect }from'dob-react'
41+
42+
@observable
43+
exportclassUserStore {
44+
name='bob'
45+
}
46+
47+
exportclassUserAction {
48+
@inject(UserStore)private UserStore:UserStore;
49+
50+
@Action setName () {
51+
this.store.name='lucy'
52+
}
53+
}
54+
55+
@Connect(combineStores({
56+
UserStore,
57+
UserAction
58+
}))
59+
classAppextendsReact.Component {
60+
render() {
61+
return (
62+
<spanonClick={this.props.UserAction.setName}>
63+
{this.props.UserStore.name}
64+
</span>
65+
)
66+
}
67+
}
68+
```
69+
70+
>Use`inject` to pick stores in action, do not`new UserStore()`, it's terrible for later maintenance.
71+
72+
##Use in react project
3773

3874
```typescript
3975
import {Action,observable,combineStores,inject }from'dob'
@@ -75,8 +111,6 @@ ReactDOM.render(
75111
,document.getElementById('react-dom'))
76112
```
77113

78-
>Use`inject` to pick stores in action, do not`new UserStore()`, it's terrible for later maintenance.
79-
80114
##Project Examples
81115

82116
-[dob-react simple example](https://github.com/ascoders/dob-example)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp