Description
相关平台
微信小程序
小程序基础库: 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
})
}
}
Activity