@@ -145,16 +145,19 @@ function useShowSpinner(loading: boolean, spinnerDelayMs: number): boolean {
145
145
safeDelay = 0 ;
146
146
}
147
147
148
- // Doing a bunch of mid-render state syncs to minimize risks of UI tearing
149
- // during re-renders. It's ugly, but it's what the React team officially
150
- // recommends (even though this specific case is extra nasty).
151
- //
152
- // Be very careful with this logic; React only bails out of redundant state
153
- // updates if they happen outside of a render. Inside a render, if you keep
154
- // calling a state dispatch, you will get an infinite render loop, no matter
155
- // what value you dispatch. There must be a "base case" in the render path
156
- // that causes state dispatches to stop entirely so that React can move on
157
- // to the next component in the Fiber subtree
148
+ /**
149
+ * Doing a bunch of mid-render state syncs to minimize risks of UI tearing
150
+ * during re-renders. It's ugly, but it's what the React team officially
151
+ * recommends (even though this specific case is extra nasty).
152
+ * @see {@link https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes }
153
+ *
154
+ * Be very careful with this logic; React only bails out of redundant state
155
+ * updates if they happen outside of a render. Inside a render, if you keep
156
+ * calling a state dispatch, you will get an infinite render loop, no matter
157
+ * what value you dispatch. There must be a "base case" in the render path
158
+ * that causes state dispatches to stop entirely so that React can move on
159
+ * to the next component in the Fiber subtree
160
+ */
158
161
const [ delayLapsed , setDelayLapsed ] = useState ( safeDelay === 0 ) ;
159
162
const [ renderCache , setRenderCache ] = useState ( { loading, safeDelay } ) ;
160
163
const canResetLapseOnRerender =
0 commit comments