Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/content/warnings/special-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Special Props Warning
---

Most props on a JSX element are passed on to the component, however, there are two special props (`ref` and `key`) which are used by React, and are thus not forwarded to the component.
Most props on a JSX element are passed on to the component. In earlier versions of React, `key` and `ref` were two special props used internally by React that were not forwarded to components.

For instance, you can't read `props.key` from a component. If you need to access the same value within the child component, you should pass it as a different prop (ex: `<ListItemWrapper key={result.id} id={result.id} />` and read `props.id`). While this may seem redundant, it's important to separate app logic from hints to React.
Starting in React 19, `ref` is available as a prop for function components, making `key` the only prop that React does not forward to the component.

For instance, you cannot read `props.key` from a component. If you need to access the same value within the child component, you should pass it as a different prop (e.g. `<ListItemWrapper key={result.id} id={result.id} />` and read `props.id`). While this may seem redundant, it's important to separate app logic from hints to React.
Loading