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

taro4.0创建的0.73版本react-native的view的onClick事件异常 #15211

Closed
a709691139 opened this issue Feb 4, 2024 · 3 comments · Fixed by #15212
Closed

taro4.0创建的0.73版本react-native的view的onClick事件异常 #15211

a709691139 opened this issue Feb 4, 2024 · 3 comments · Fixed by #15212
Assignees
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@a709691139
Copy link
Contributor

相关平台

React Native

复现仓库

https://github.com/a709691139/taro4.0.git

使用框架: React

复现步骤

随便写个onClick useState, 然后点击几次view,就发现onClick事件一直是旧的

import { useState } from 'react';
import { View } from '@tarojs/components';

const Index = () => {
  const [staticed, setStaticed] = useState(false);
  return (
    <View>
      formStaticed: {JSON.stringify(staticed)}
      <View
        onClick={() => {
          console.log('old value ', staticed);
          setStaticed(!staticed);
        }}>
        切换
      </View>
    </View>
  );
};
export default Index;

期望结果

console.log('old value ', staticed);
这里的输出永远是false

实际结果

应该是true或false轮着来

环境信息

👽 Taro v4.0.0-beta.8


  Taro CLI 4.0.0-beta.8 environment info:
    System:
      OS: Windows 11 10.0.22621
    Binaries:
      Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
      npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/components: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/components-rn: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/helper: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-framework-react: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-alipay: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-h5: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-jd: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-qq: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-swan: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-tt: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/plugin-platform-weapp: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/react: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/rn-runner: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/rn-supporter: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/runtime: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/runtime-rn: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/shared: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/taro: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/taro-loader: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/taro-rn: 4.0.0-beta.8 => 4.0.0-beta.8 
      @tarojs/webpack5-runner: 4.0.0-beta.8 => 4.0.0-beta.8 
      babel-preset-taro: 4.0.0-beta.8 => 4.0.0-beta.8 
      eslint-config-taro: 4.0.0-beta.8 => 4.0.0-beta.8 
      expo: ~50.0.2 => 50.0.4 
      react: ^18.2.0 => 18.2.0 
      react-native: ^0.73.1 => 0.73.3 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x labels Feb 4, 2024
@a709691139
Copy link
Contributor Author

a709691139 commented Feb 4, 2024

7269222e47ee0f739688cae34ddd053
这里是运行结果

@a709691139
Copy link
Contributor Author

找到解决方法了,因为PanResponder拿到的值都是旧的, props要改用ref来获取
78d9294a678b3122e67ec5a2e711754

@a709691139 a709691139 mentioned this issue Feb 4, 2024
18 tasks
@a709691139
Copy link
Contributor Author

#15212
关联pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants