Skip to content

src/utils/index.js中的randomId()函数可能产生相同的结果 #1

@12eagleking

Description

@12eagleking

src/components/SideBar/index.js文件中,类组件SideBarrenderSocialLink函数中的数组元素组件中的key使用了randomId()函数生成:

  • 组件中引用的src/utils/index.js中的randomId()函数,多次运行的结果中,可能有两次或更多次的结果相同,这样可能使得一组数组组件元素的key重复不唯一
  • 数组元素组件的key为什么要使用randomId()?相比常规的arr.map((value, index) => <Component key={index} />)有什么好处?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions