Bug: useReducer bail-out w/ useEffect + Suspense causes infinite loop (StrictMode error with next/experimental builds)

This issue has been created since 2022-09-03.

I just found our lib doesn't pass tests with latest build (unreleased ones). pmndrs/jotai#1370

React version: 18.3.0-next-3d443cad7-20220823

Steps To Reproduce

const Component = () => {
  const [count, dispatch] = useReducer((prev) => prev, 0);
  useEffect(() => {
    dispatch();
  }, []);
  return <>{count}</>;
};

const App = () => (
  <Suspense>
    <Component />
  </Suspense>
);

Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

Link to code example: https://codesandbox.io/s/focused-andras-p9qyxu?file=/src/App.js

The current behavior

Warning in StrictMode.

The expected behavior

No warning in StrictMode.

#25049 seems related. I'm not sure if it's a bug or a misusage.

sammy-SC wrote this answer on 2022-09-09

Resolved in #25203

thank you for the report!

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-09-27
Star Count 195296
Watcher Count 6655
Fork Count 40431
Issue Count 1113

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
clang-format extension for VSCodium 1 2021-08-19 2022-09-26
http_message_buffer_grow函数存在潜在风险 0 2021-04-01 2022-09-24
Updating procedure seems not working 17 2021-06-18 2022-09-01
gcr-prompter, ungoogled-chromium application wants access to Default keyring 6 2020-11-17 2022-09-22
Strange behavior from Metadata.sign() and Metadata.to_file() 11 2022-01-31 2022-09-19
Cannot get certain playlist's tracks 3 2021-03-15 2022-08-25
[Feature Request] Version docs 3 2022-03-25 2022-08-15
[Question] Is there any plan for trio support? 3 2021-11-20 2022-08-21
(Re)Define the robot image grey/plain rendering based on chosen robot state 1 2021-06-24 2022-09-17
🐛 IconButton look weird and the size diverge between primary and secondary variants 6 2021-12-07 2022-07-26
🐛 Autocomplete color is not dark mode friendly 1 2021-12-06 2022-07-03
No feed entries are shown when Raven Reader is connected to Miniflux via Fever API 0 2022-01-07 2022-09-17
[Bug] [Serve] Autoscaling min_replicas doesn't work 0 2021-10-06 2022-07-29
Logging may log transactions to debug.log 0 2020-10-20 2022-09-19
TelegramBotHandler throws when Telegram API returns "message is too long" error 2 2021-03-17 2022-08-04
Unexpected offset motion of print head, during print 8 2022-05-05 2022-09-13
Volatility 3 doesn't work with fresh Windows builds in crashdump64 format 4 2021-03-07 2022-09-15
syncfusion_flutter_datagrid 2 2021-09-29 2022-09-25
Entire router stops responding periodically 6 2021-12-30 2022-08-08
Chrome-like tab groups 1 2022-07-27 2022-09-18
Manifest Validation Fails on HighResolutionIconURL and IconURL Errors 13 2020-12-02 2022-09-05
[email protected]: Disk image license agreements are deprecated by Apple and will probably be removed in a future macOS release. 8 2022-02-23 2022-09-24
Adding driver for Tiff images 9 2022-08-01 2022-09-13
RTK-Query: Code Splitting plus rehydration? 22 2022-08-11 2022-09-26
What is the usage of --security-checks? 6 2022-01-24 2022-09-20
RFC 9266: Channel Bindings for TLS 1.3 support 0 2022-08-03 2022-09-22
DOC: mention PEP 600 in `README.rst` 2 2021-04-01 2022-09-25
Logo too small on buy now subscription 4 2022-09-04 2022-09-16
Add knowledge base statistics dashboard 0 2021-11-16 2022-07-24
Fez does not add the "zef:" prefix in the fez user config file as expected by App::Mi6 5 2021-12-04 2022-09-11
idea: changelogs in markdown format 1 2022-03-13 2022-09-11
todo: support windows 0 2022-03-12 2022-09-11
divide_and_round_q_last_inplace math 12 2022-01-21 2022-09-15
请问配置文件如何配置 1 2021-12-31 2022-01-14
Recursive PartialEq implementation not detected 2 2022-07-13 2022-07-25
Print stdout when package publish fails 1 2022-05-23 2022-09-08
How to pull from Upstream? 11 2020-08-14 2022-09-23
duplicati-cli is missing 2 2022-05-24 2022-09-16
[DocDB] Time window compaction (TTL expiry) 0 2021-12-16 2022-09-09
Service "t_fox_mpdf_port.pdf" not found... 0 2021-01-03 2022-09-02
issue in useOddEven 1 2022-06-28 2022-09-27
Add new QA contact to Bugzilla Train deploy bug 1 2022-08-08 2022-08-15
[subplat] Breadcrumb menu option are no longer a link after browser resize 1 2022-08-05 2022-08-15
l10n export is broken (Fatal error: Unexpected token (93:10)) 12 2022-08-05 2022-08-15
The “Would you mind telling us why you’re leaving?” form can be submitted without checking an option 1 2022-08-05 2022-08-15
Font sizes are different (12px vs 14px) for various connected services 1 2022-08-08 2022-08-15
[hackerone] security tokens issue 3 2022-08-15 2022-08-31
Produces G1 and G2 points of different length. 4 2022-01-06 2022-09-18
Tab index 0 is set on every radio input inside a popover when interacting via keyboard 2 2022-02-23 2022-09-20
The default MAUI and MAUI-Blazor projects do not work when published for Windows. 2 2022-01-09 2022-09-25