Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix can't get correct state #95

Merged
merged 3 commits into from
Apr 10, 2020

Conversation

luhc228
Copy link
Member

@luhc228 luhc228 commented Apr 10, 2020

问题描述

model 中的 state 初始值为0时,通过 useModelState API 获取 state 报错。

原因为

 const selector = store.useSelector(state => state[name]);
        if (selector) { // 当这里的selector === 0 statement为faslse, 无法正常返回 modelstate
          return selector;
        }

fix

   if (selector !== undefined) { 
          return selector;
   }

@luhc228 luhc228 self-assigned this Apr 10, 2020
@luhc228 luhc228 requested a review from alvinhui April 10, 2020 02:38
@@ -21,14 +21,14 @@ export default (): T.Plugin => {
}
function useModelState(name: string) {
const selector = store.useSelector(state => state[name]);
if (selector) {
if (selector !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof 一下更合适

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@alvinhui alvinhui changed the base branch from master to release/1.3.4 April 10, 2020 02:47
@alvinhui alvinhui merged commit d139c84 into ice-lab:release/1.3.4 Apr 10, 2020
alvinhui added a commit that referenced this pull request Apr 10, 2020
* chore: model validate show name

* fix: fix can't get correct state (#95)

* fix: fix can't get correct state

* chore: update version

* fix: fix by the comment

* docs: readonly && get the latest state

Co-authored-by: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants