Repository navigation
fix-forward #4011 (tsk-br5bqw): reset the mounted ref on effect start so StrictMode's remount does not discard every load #4017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ### Fixed | ||
| - reset the mounted ref on effect start so StrictMode's remount does not discard every load |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ export function WifiPanel() { | |
| const mounted = useRef(true); | ||
|
|
||
| useEffect(() => { | ||
| mounted.current = true; | ||
| const load = async () => { | ||
|
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent older Wi-Fi loads from replacing newer state. When StrictMode restarts this effect, resetting
|
||
| try { | ||
| const res = await fetch("/api/hardware/wifi", { credentials: "include" }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent older Bluetooth loads from replacing newer state.
When StrictMode restarts this effect,
mounted.current = truealso reactivates a request from the cleaned-up effect. If that request finishes after the new request, it can replace newer device data or restore an old error. The 10-second interval creates the same race when a load takes more than 10 seconds. Use an effect-local cleanup flag and a request sequence check before applying each result or error. (react.dev)