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

React Native无法获取Input、Text等组件的ref #15380

Open
Hooych opened this issue Mar 21, 2024 · 0 comments
Open

React Native无法获取Input、Text等组件的ref #15380

Hooych opened this issue Mar 21, 2024 · 0 comments
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@Hooych
Copy link

Hooych commented Mar 21, 2024

相关平台

React Native

使用框架: React

复现步骤

https://taro-docs.jd.com/docs/ref

按照文档编写代码,使用最新版本taro,在ReactNative端无法获取到ref

期望结果

正常获取ref

实际结果

inputRef. {"current": null}

环境信息

👽 Taro v3.6.25


  Taro CLI 3.6.25 environment info:
    System:
      OS: macOS 14.3.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
      Yarn: 1.22.21 - ~/.nvm/versions/node/v18.17.0/bin/yarn
      npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
    npmPackages:
      @tarojs/cli: ^3.6.25 => 3.6.25 
      @tarojs/components: ^3.6.25 => 3.6.25 
      @tarojs/components-rn: ^3.6.25 => 3.6.25 
      @tarojs/helper: ^3.6.25 => 3.6.25 
      @tarojs/plugin-framework-react: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-alipay: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-h5: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-jd: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-qq: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-swan: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-tt: ^3.6.25 => 3.6.25 
      @tarojs/plugin-platform-weapp: ^3.6.25 => 3.6.25 
      @tarojs/react: ^3.6.25 => 3.6.25 
      @tarojs/rn-runner: ^3.6.25 => 3.6.25 
      @tarojs/rn-supporter: ^3.6.25 => 3.6.25 
      @tarojs/runtime: ^3.6.25 => 3.6.25 
      @tarojs/runtime-rn: ^3.6.25 => 3.6.25 
      @tarojs/shared: ^3.6.25 => 3.6.25 
      @tarojs/taro: ^3.6.25 => 3.6.25 
      @tarojs/taro-loader: ^3.6.25 => 3.6.25 
      @tarojs/taro-rn: ^3.6.25 => 3.6.25 
      @tarojs/webpack5-runner: ^3.6.25 => 3.6.25 
      babel-preset-taro: ^3.6.25 => 3.6.25 
      eslint-config-taro: ^3.6.25 => 3.6.25 
      expo: ~47.0.3 => 47.0.14 
      react: ^18.1.0 => 18.2.0 
      react-native: ^0.70.5 => 0.70.15 


补充信息

View、Button等组件可以正常获取ref,
观察components-rn中View使用了forwardRef,Button是class组件,而Input是函数组件且未使用forwardRef,是否故意如此设计?什么原因?

@taro-bot2 taro-bot2 bot added F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x labels Mar 21, 2024
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

No branches or pull requests

1 participant