refactor: 如果 props.foo === undefind 不是一个合法的属性值,那应该用比 in 更严格的判断 #141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
对 InputNumber 这个组件来说,props.precision 和 props.decimalSeparator 值如果是 undefined,则这是一个非法的 props 值,会导致组件逻辑直接挂掉。
当然,正常情况,在 jsx 里,用户不会故意写出
<InputNumber decimalSeparator={ undefined }>这样的代码但是考虑一些复杂业务里的这种受控情况
<InputNumber decimalSeparator={ this.state.bar }>出问题的概率就会大一些此外,在基于 antd 的可视化配置建站的产品中,可视化的属性面板比较难表达 optional 的 props.decimalSeparator 值是 undefined 和 props 没有 decimalSeparator 这个 key 这两种情况
方案
rc-input-number 代码里的判断稍微严格一点