taro icon indicating copy to clipboard operation
taro copied to clipboard

fix(runtime): removeEventListener时组件不在componentsAlias引发报错

Open liulinboyi opened this issue 1 year ago • 0 comments

PR信息

这个 PR 是什么类型? (至少选择一个)

  • [x] 错误修复(Bugfix) issue: #16012

这个 PR 涉及以下平台:

  • [x] 所有小程序

最小复现

仓库 https://github.com/liulinboyi/taro-removeEventListener-bug

代码

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

export default function Index() {
  const [flag, setFlag] = useState(true)

  return (
    <View className='index'>
      <View className='wrapper'>
        {
          flag ?
            <Text className='box' onClick={() => setFlag(prev => !prev)}>Demo {flag ? '1' : '0'}</Text> :
            <Text className='box'>Other {flag ? '1' : '0'}</Text>
        }
      </View>
    </View>
  )
}

上述代码编译后运行在微信小程序中时,点击Demo 1时,在控制台会抛出错误如下:

demo_bug

修复

修复后如下:

demo_bug_2

liulinboyi avatar Jun 29 '24 15:06 liulinboyi