ice-lab / icestore

🌲 Simple and friendly state for React
MIT License
397 stars 35 forks source link

fix: fix can't get correct state #95

Closed luhc228 closed 4 years ago

luhc228 commented 4 years ago

问题描述

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;
   }