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

INPUT组件删除为什么表现不一致 #13120

Closed
MelodyLLL opened this issue Jan 10, 2023 · 1 comment · Fixed by #13543
Closed

INPUT组件删除为什么表现不一致 #13120

MelodyLLL opened this issue Jan 10, 2023 · 1 comment · Fixed by #13543
Assignees
Labels
bug Something isn't working F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@MelodyLLL
Copy link

MelodyLLL commented Jan 10, 2023

相关平台

微信小程序

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

复现步骤

const MyInput = () => {
  const [num, setNum] = useState(99);
  return (
    <Input
      onInput={(e) => {
        if (!e.detail.value) {
          setNum(1);
        } else {
          setNum(e.detail.value);
        }
      }}
      value={num}
    />
  );
};

class MyInput2 extends Component {
  constructor(props) {
    super(props);
    this.state = {
      num: 88,
    };
  }

  render() {
    return (
      <Input
        onInput={(e) => {
          if (!e.detail.value) {
            this.setState({
              num: 1,
            });
          } else {
            this.setState({ num: e.detail.value });
          }
        }}
        value={this.state.num}
      />
    );
  }
}

期望结果

在hooks组件中 受控的值会刷新input value

实际结果

在hooks组件中 当删除为空时,第一次会刷新为1,但是第二次会导致input框直接没值

环境信息


  Taro CLI 3.5.7 environment info:
    System:
      OS: macOS 12.6
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 14.19.1 - ~/.nvm/versions/node/v14.19.1/bin/node
      Yarn: 1.18.0 - ~/.nvm/versions/node/v14.19.1/bin/yarn
      npm: 8.19.1 - ~/.nvm/versions/node/v14.19.1/bin/npm
    npmPackages:
      @tarojs/components: 3.5.6 => 3.5.6 
      @tarojs/plugin-framework-react: 3.5.6 => 3.5.6 
      @tarojs/react: 3.5.6 => 3.5.6 
      @tarojs/runtime: 3.5.6 => 3.5.6 
      @tarojs/taro: 3.5.6 => 3.5.6 
      @tarojs/webpack5-runner: ^3.5.6 => 3.5.6 
      babel-preset-taro: 3.5.6 => 3.5.6 
      eslint-config-taro: 3.5.6 => 3.5.6 
      react: ^18.2.0 => 18.2.0 

补充信息

如代码两个组件 执行删除操作
hooks 组件表现 99 > 9 > 1 > 空
class 组件表现 88 > 8 >. 1 > ....> 1

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 10, 2023
@MelodyLLL MelodyLLL changed the title INPUT组件删除为什么会更新异常 INPUT组件删除为什么表现不一致 Jan 11, 2023
@AdvancedCat
Copy link
Member

感谢指出,这确实是个bug,会尽快安排修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants