Skip to content

Commit 2ac1279

Browse files
committed
docs: mention createReactClass derived state
1 parent 6ec6134 commit 2ac1279

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/content/reference/react/Component.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,8 @@ Deriving state leads to verbose code and makes your components difficult to thin
10131013
10141014
- This method doesn't have access to the component instance. If you'd like, you can reuse some code between `static getDerivedStateFromProps` and the other class methods by extracting pure functions of the component props and state outside the class definition.
10151015
1016+
- If your legacy component is defined with [`createReactClass`](https://legacy.reactjs.org/docs/react-without-es6.html), define `getDerivedStateFromProps` in the `statics` object.
1017+
10161018
<Note>
10171019
10181020
Implementing `static getDerivedStateFromProps` in a class component is equivalent to [calling the `set` function from `useState` during rendering](/reference/react/useState#storing-information-from-previous-renders) in a function component.

0 commit comments

Comments
 (0)