GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — StrictMode should call sCU twice in DEV (#17942) · react/react@6ae2c33

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-reconciler/src
      • ReactFiberClassComponent.js
    • react/src/__tests__
      • ReactStrictMode-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-reconciler/src/ReactFiberClassComponent.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberClassComponent.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ function checkShouldComponentUpdate(
262262
) {
263263
const instance = workInProgress.stateNode;
264264
if (typeof instance.shouldComponentUpdate === 'function') {
265+
if (__DEV__) {
266+
if (
267+
debugRenderPhaseSideEffectsForStrictMode &&
268+
workInProgress.mode & StrictMode
269+
) {
270+
// Invoke the function an extra time to help detect side-effects.
271+
instance.shouldComponentUpdate(newProps, newState, nextContext);
272+
}
273+
}
265274
startPhaseTimer(workInProgress, 'shouldComponentUpdate');
266275
const shouldUpdate = instance.shouldComponentUpdate(
267276
newProps,
Collapse file

‎packages/react/src/__tests__/ReactStrictMode-test.js‎

Copy file name to clipboardExpand all lines: packages/react/src/__tests__/ReactStrictMode-test.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ describe('ReactStrictMode', () => {
138138
'getDerivedStateFromProps',
139139
'getDerivedStateFromProps',
140140
'shouldComponentUpdate',
141+
'shouldComponentUpdate',
141142
'render',
142143
'render',
143144
'componentDidUpdate',
@@ -166,6 +167,7 @@ describe('ReactStrictMode', () => {
166167
'getDerivedStateFromProps',
167168
'getDerivedStateFromProps',
168169
'shouldComponentUpdate',
170+
'shouldComponentUpdate',
169171
]);
170172
} else {
171173
expect(log).toEqual([
@@ -283,6 +285,7 @@ describe('ReactStrictMode', () => {
283285
'getDerivedStateFromProps',
284286
'getDerivedStateFromProps',
285287
'shouldComponentUpdate',
288+
'shouldComponentUpdate',
286289
'render',
287290
'render',
288291
'componentDidUpdate',
@@ -305,6 +308,7 @@ describe('ReactStrictMode', () => {
305308
'getDerivedStateFromProps',
306309
'getDerivedStateFromProps',
307310
'shouldComponentUpdate',
311+
'shouldComponentUpdate',
308312
]);
309313
} else {
310314
expect(log).toEqual([

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.