-3

I have to set an attribute to the fragment. I want to do something like this:

<className="name">
  abcd
</>

Is there any way to do like this?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
wantyouring
  • 187
  • 2
  • 13
  • 3
    [*"You can use `<>>` the same way you’d use any other element except that it doesn’t support keys or attributes."*](https://reactjs.org/docs/fragments.html#short-syntax) Even with the non-shorthand syntax, per the same page, a fragment only supports a `key` attribute. – jonrsharpe Aug 11 '20 at 10:25
  • Thank you for your answer jonrsharpe! – wantyouring Aug 11 '20 at 10:32

1 Answers1

0

You can't since it's React specific and not an HTML tag. Here is what the docs say:

You can use <></> the same way you’d use any other element except that it doesn’t support keys or attributes.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Lafi
  • 1,310
  • 1
  • 15
  • 14