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.

"Warning: u: `key` is not a prop" in console.

See original GitHub issue

Great tree view component, very powerful and easy to use. Thank you for releasing it!

I just implemented it and followed the data structure as per the documentation. In my console react is throwing an error:

Warning: u: key is not a prop. Trying to access it will result in undefined being returned. If you need to access the same value within the child component, you should pass it as a different prop.

Is this something that I can fix or will it require a update to the component code?

Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iannbingcommented, Jul 10, 2019

Ah, sorry my bad.

My example code above isn’t correct. In order to prevent all the warnings of such kind. You need a custom component to explicitly consumes the props instead of using native elements like li.

You can check how I implement it here.

0reactions
AvishekNathcommented, Aug 29, 2019

Still getting error --> Warning: u: key is not a prop. Trying to access it will result in undefined being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://fb.me/react-special-props)

Code–>

const treeData = [ { key: “first-level-node-1”, id: “first-level-node-1”, label: “Node 1 at the first level”, nodes: [ { key: “second-level-node-1”, id: “second-level-node-1”, label: “Node 1 at the second level”, nodes: [ { key: “third-level-node-1”, id: “third-level-node-1”, label: “Last node of the branch”, nodes: [] // you can remove the nodes property or leave it as an empty array } ] } ] }, { key: “first-level-node-2”, id: “first-level-node-2”, label: “Node 2 at the first level” } ];

<TreeMenu hasSearch={true} data={treeData} onClickItem={node => { //this.handleTreeClick(node); }} > {({ search, items }) => (

    {items.map(({ key, …props }) => ( <ItemComponent {…props} key={props.id} /> ))}
)} </TreeMenu>

Please help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: `key` is not a prop - Stack Overflow
Everything works for me but in the console I get a warning:​​ When I click on a note, I transfer the data to...
Read more >
Key is not a prop. Trying to access it will result in `undefined`
The warning " key is not a prop. Trying to access it will result in undefined being returned" is caused when we try...
Read more >
How to resolve React console warnings about unique `key ...
Warning: Fr: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the...
Read more >
Warning: Each Child in a List Should Have a Unique 'key' Prop
When creating a list in the UI from an array with JSX, you should add a key prop to each child and to...
Read more >
Everything you need to know about the key prop in React
Software Engineer Not responding… ... Well, we now see the list of our items, but what is this warning in our console? ......
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