Skip to content

Commit bbef436

Browse files
committed
docs(warnings): update special-props warning for React 19 ref prop forwarding
1 parent f3d9794 commit bbef436

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/content/warnings/special-props.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Special Props Warning
33
---
44

5-
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.
5+
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.
66

7-
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.
7+
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.
8+
9+
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.

0 commit comments

Comments
 (0)