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

function component 对input组件的变化有问题 #9241

Closed
conan51551 opened this issue Apr 30, 2021 · 1 comment
Closed

function component 对input组件的变化有问题 #9241

conan51551 opened this issue Apr 30, 2021 · 1 comment

Comments

@conan51551
Copy link

相关平台

微信小程序

复现仓库

https://github.com/conan51551/taro-demo

小程序基础库: 3.2.5
使用框架: React


function InputNumber(props) {
  const { num, change } = props;

  console.log(num, "num");

  const handleBlur = (e) => {
    const value = Number(e.detail.value);
    if (value >= 5) {
      change(5);
    } else {
      change(value);
    }
  };

  return (
    <View>
      <Input
        type="number"
        onBlur={handleBlur}
        value={props.num}
        key={props.num}
      />
    </View>
  );
}
export default InputNumber;
<InputNumber
      num={this.state.num}
      change={this.changeNum}
/>

同样这样使用InputNumber组件,在如果是用hook定义的function component 情况下,只有第一次当输入的数字大于5才能被改成5

期望结果

当输入大于5的数字,数字每次都被改成5

实际情况

在class componet中可以,但是在hook的function component中,只有第一次被修改成了5

@taro-bot2
Copy link

taro-bot2 bot commented Apr 30, 2021

您的 Issue 没有按照规范从 Taro Issue Helper 创建,因此会被直接关闭。

维护开源项目是一项非常辛苦的工作,还请多多包涵。
了解为什么这么严格?

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

No branches or pull requests

2 participants