-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportBase: 82.12% // Head: 82.12% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## release-next #504 +/- ##
=============================================
Coverage 82.12% 82.12%
=============================================
Files 90 90
Lines 7669 7669
Branches 971 971
=============================================
Hits 6298 6298
Misses 1364 1364
Partials 7 7 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
website/docs/guide/plugins/store.md
Outdated
|
||
export default store.withModel('todos')(TodoList); | ||
// 绑定多个 model | ||
// export default withModel('user')(withModel('todos')(TodoList)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否默认推荐 decorator 的形式包装 component:
- ts 里需要在 tsconfig 里添加 compilerOptions 的
"experimentalDecorators": true 才可启用 - ts 不支持为 function 添加 decoration
- 需要在项目中依赖 tslib
个人建议:
- withModel 仅开放给 Class Component, 默认用 decorators
- 对于 Function Component 还是推荐用 hooks 的方式
冲突了 |
order: 2 | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以提供个示例组件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
封装了一个组件后,样式就出不来了
website/docs/guide/plugins/store.md
Outdated
|
||
## 全局状态 | ||
|
||
推荐在不同页面组件中使用的状态存放在全局状态中,比如主题、国际化语言、用户信息等。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
推荐在不同页面组件中使用的状态存放在全局状态中
-> 推荐在不同页面组件中共享的状态存放在全局状态中
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
website/docs/guide/plugins/store.md
Outdated
|
||
```diff | ||
import { useEffect } from 'react'; | ||
import store from '@/store'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
少了 + 号
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
// const data = (await fetch('your-url')).json(); | ||
return { | ||
initialStates: { | ||
user: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
models/user.ts 和 models/counter.ts 内容怎么写有没有限制,这个键值是跟文件名对应吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已补充
website/docs/guide/plugins/store.md
Outdated
#### reducers | ||
|
||
```ts | ||
reducers: { [string]: (prevState, payload) => any } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用标准类型的写法 说明下这个是 reducers 的类型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
website/docs/guide/plugins/store.md
Outdated
reducers: { [string]: (prevState, payload) => any } | ||
``` | ||
|
||
一个改变该模型状态的函数集合。这些方法以模型的上一次 prevState 和一个 payload 作为入参,在方法中使用可变的方式来更新状态。这些方法应该是仅依赖于 prevState 和 payload 参数来计算下一个 nextState 的纯函数。对于有副作用的函数,请使用 effects。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevState / payload / nextState / effects 术语要不要统一说明下是什么意思,effects 下面有说明的可以直接链接过去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
website/docs/guide/plugins/store.md
Outdated
#### effects | ||
|
||
```ts | ||
effects: (dispatch) => ({ [string]: (payload, rootState) => void }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上 type Effects = xxx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
website/docs/guide/plugins/store.md
Outdated
effects: (dispatch) => ({ [string]: (payload, rootState) => void }) | ||
``` | ||
|
||
一个可以处理该模型副作用的函数集合。这些方法以 payload 和 rootState 作为入参,适用于进行异步调用、模型联动等场景。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootState 的说明
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
website/docs/guide/plugins/store.md
Outdated
</Tabs> | ||
|
||
|
||
### Model 中使用 immer 更改 State |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
标题倾向于:不可变状态,然后说明推荐状态不可变,并且可以通过开启 immer 的方式来将简化不可变操作
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
website/docs/guide/plugins/store.md
Outdated
}) | ||
``` | ||
|
||
### 获取 effects 的 loading/error 状态 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
获取内置状态:加载状态、错误状态
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
顺带修复了 diff 语法不高亮的问题(是配置的主题引起的)