Skip to content

Commit

Permalink
Fixing component key warning (gatsbyjs#2148)
Browse files Browse the repository at this point in the history
Key should be set on the component instead of inside of it. Setting the key inside the component will cause a warning and not actually set the key. You can see this listed as incorrect usage here: https://facebook.github.io/react/docs/lists-and-keys.html#extracting-components-with-keys
  • Loading branch information
morganick authored and KyleAMathews committed Sep 18, 2017
1 parent 41b5786 commit 1a6a7dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/using-contentful/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const propTypes = {
}

const Product = ({ node }) => (
<div key={node.id}>
<div>
<Link
style={{ color: `inherit`, textDecoration: `none` }}
to={`/products/${node.id}/`}
Expand Down Expand Up @@ -63,11 +63,11 @@ class IndexPage extends React.Component {
nodes from a single locale
</p>
<h3>en-US</h3>
{usProductEdges.map(({ node }, i) => <Product node={node} />)}
{usProductEdges.map(({ node }, i) => <Product node={node} key={node.id} />)}
<br />
<br />
<h3>de</h3>
{deProductEdges.map(({ node }, i) => <Product node={node} />)}
{deProductEdges.map(({ node }, i) => <Product node={node} key={node.id} />)}
</div>
)
}
Expand Down

0 comments on commit 1a6a7dc

Please sign in to comment.