question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how add key for fragment

See original GitHub issue

before i use

<Fragment key={index}> now i use

<>

how add key this ?

< key={index}> has error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

9reactions
TrySoundcommented, Oct 14, 2018

@uxitten Syntax works only for propless fragments. If you need to add key, just use React.Fragment. There’s nothing wrong with it.

8reactions
TrySoundcommented, Oct 15, 2018

Isn’t this clean enough? https://reactjs.org/docs/fragments.html image image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I add a key prop to a React fragment? - Stack Overflow
Yes, you can add a key in the below form Fragment which is not possible in the shorter version of Fragments ...
Read more >
Keyed Fragments - React
In most cases, you can use the key prop to specify keys on the elements you're returning from render . However, this breaks...
Read more >
How to add a key prop to a React Fragment | bobbyhadz
Use the more verbose syntax of fragments to add a key prop to a React fragment, e.g. <React.Fragment key={key}> . The more verbose...
Read more >
React Fragments in Practice – 4 real-world examples
Learn how to use React Fragments let to group React elements, without requiring unnecessary markup or confusing key props.
Read more >
React Fragments - Uses, Examples, Practices - KnowledgeHut
Yes, React. Fragments can have a key, but the shorter syntactic sugar form of React Fragment does not support keys and attributes. Tags....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found