Skip to content

Commit 2762bb5

Browse files
docs: put Strict Mode caveat first and tighten iterator warning
1 parent 690d2c8 commit 2762bb5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/content/reference/react/Component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,10 @@ You should write the `render` method as a pure function, meaning that it should
581581
582582
- `render` will not get called if [`shouldComponentUpdate`](#shouldcomponentupdate) is defined and returns `false`.
583583
584-
- If you return an iterator from `render`, make sure each render creates a fresh iterator. React may render more than once in development, and a reused iterator may already be consumed. When possible, prefer returning an array or another reusable iterable.
585-
586584
- When [Strict Mode](/reference/react/StrictMode) is on, React will call `render` twice in development and then throw away one of the results. This helps you notice the accidental side effects that need to be moved out of the `render` method.
587585
586+
- If you return an iterator from `render`, make sure each render creates a fresh iterator. Iterators are consumed on use, so a reused iterator may already be empty. When possible, prefer returning an array or another reusable iterable.
587+
588588
- There is no one-to-one correspondence between the `render` call and the subsequent `componentDidMount` or `componentDidUpdate` call. Some of the `render` call results may be discarded by React when it's beneficial.
589589
590590
---

0 commit comments

Comments
 (0)