Skip to content

[new feature] support array in the className #16705

@coppyC

Description

@coppyC

I konw the classnames package can resolve the problem,
but I want react support this by default without classnames package.

classnames is good, but when I want to use it, I should type a long name,
and the mostly time, I don't have installd it, but I need to do a little code to merge classname to install it.

and a little different to classnames

  • className can accept a array (any[]), not support object.
  • className still accept a string
<div className={['a', 'b']}></div>

to

<div className="a b"></div>

and filter the string item to be the className
this can do some conditions, like jsx (true &&

)

<div className={[
  'a b c',
  true && 'd',
  false && 'f',
  null && 'g',
  0 && 'h',
  undefined && 'i',
]}></div>

to

<div className="a b c d"></div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions