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

TypeError: Cannot read property '_num' of undefined #16641

Open
cexll opened this issue Oct 4, 2024 · 4 comments
Open

TypeError: Cannot read property '_num' of undefined #16641

cexll opened this issue Oct 4, 2024 · 4 comments
Labels
A-runtime Area - 运行时相关

Comments

@cexll
Copy link

cexll commented Oct 4, 2024

相关平台

微信小程序

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

复现步骤

参考当前链接 https://juejin.cn/post/7166431631731851271
代码中存在useState , 组件存在onClick等事件
复现步骤
写一个组件通过useState来控制打开与关闭
const [isShowLogin, setIsShowLogin] = useState(false);

const handleCloseLogin = () => {
setIsShowLogin(!isShowLogin);
}

期望结果

期望程序能够正常运行

实际结果

程序直接报错 TypeError: Cannot read property '_num' of undefined

环境信息

👽 Taro v3.6.35


  Taro CLI 3.6.35 environment info:
    System:
      OS: macOS 14.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
      Yarn: 1.22.19 - /opt/homebrew/bin/yarn
      npm: 10.8.2 - ~/.nvm/versions/node/v20.9.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.24 => 3.6.24 
      @tarojs/components: 3.6.24 => 3.6.24 
      @tarojs/helper: 3.6.24 => 3.6.24 
      @tarojs/mini-runner: 3.6.24 => 3.6.24 
      @tarojs/plugin-framework-react: 3.6.24 => 3.6.24 
      @tarojs/plugin-html: 3.6.24 => 3.6.24 
      @tarojs/plugin-mini-ci: 3.6.24 => 3.6.24 
      @tarojs/plugin-platform-weapp: 3.6.24 => 3.6.24 
      @tarojs/react: 3.6.24 => 3.6.24 
      @tarojs/runtime: 3.6.24 => 3.6.24 
      @tarojs/shared: 3.6.24 => 3.6.24 
      @tarojs/taro: 3.6.24 => 3.6.24 
      @tarojs/taro-loader: 3.6.24 => 3.6.24 
      @tarojs/webpack-runner: 3.6.24 => 3.6.24 
      @tarojs/webpack5-runner: 3.6.24 => 3.6.24 
      babel-preset-taro: 3.6.24 => 3.6.24 
      eslint-config-taro: 3.6.24 => 3.6.24 
      react: ^18.0.0 => 18.2.0 

补充信息

TypeError: Cannot read property '_num' of undefined
at TaroElement.removeEventListener (.._src_dom_element.ts:388)
at setEvent (.._src_props.ts:72)
at setProperty (.._src_props.ts:132)
at updatePropsByPayload (.._src_props.ts:22)
at commitUpdate (.._src_reconciler.ts:141)
at Rg (._node_modules_react-reconciler_cjs_react-reconciler.production.min.js:155)
at Ug (._node_modules_react-reconciler_cjs_react-reconciler.production.min.js:161)
at Th (._node_modules_react-reconciler_cjs_react-reconciler.production.min.js:189)
at Nh (._node_modules_react-reconciler_cjs_react-reconciler.production.min.js:187)
at Eh (._node_modules_react-reconciler_cjs_react-reconciler.production.min.js:177)(env: macOS,mp,1.06.2409131; lib: 3.2.2)

错误代码
public removeEventListener (type, handler, sideEffect = true) {
super.removeEventListener(type, handler)

const name = this.nodeName
const SPECIAL_NODES = hooks.call('getSpecialNodes')!

hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias)

if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
  const componentsAlias = getComponentsAlias()
  const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`
  const valueAlias = componentsAlias[value]._num
  this.enqueueUpdate({
    path: `${this._path}.${Shortcuts.NodeName}`,
    value: valueAlias
  })
}

}

@cexll
Copy link
Author

cexll commented Oct 4, 2024

image

@cexll
Copy link
Author

cexll commented Oct 4, 2024

pure-text not fund
image
image

@cexll
Copy link
Author

cexll commented Oct 4, 2024

@cexll
Copy link
Author

cexll commented Oct 4, 2024

我将代码中 <Text className=''>123</Text> 相关代码全部改成 <View className=''>123</View> 就可以了
但我认为这是一个bug , 所有组件应该都会存在props
image
image

This was referenced Oct 5, 2024
@koppthe koppthe added the A-runtime Area - 运行时相关 label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area - 运行时相关
Projects
None yet
Development

No branches or pull requests

2 participants