类函数式组件 如何 绑定 key



  • 如代码,这种写法怎么给 类函数组件绑定 key

      renderItem ({icon, color, title}) {
        return (
          <View className='app' key={title}>
            <View className='app__icon'><Iconfont icon={icon} color={color} /></View>
            <View className='app__title'>{title}</View>
          </View>
        )
      }
    
      render() {
        const { items , title : appTitle = ''} = this.props
        return (
          <View className='apps'>
            <View className='apps__title'>{appTitle}</View>
            <View className='apps__items'>
              {items.map(c => this.renderItem(c))}
            </View>
          </View>
        )
      }
    

登录后回复