GeezerVison is showing github.com — Console Logging for StrictMode Double Rendering (#22030) · react/react@60a30cf
File treeExpand file treeCollapse file tree Open diff view settings react-devtools-extensions react-devtools-shared/src
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/src/standalone.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,6 +21,7 @@ import { | 21 | 21 | getBreakOnConsoleErrors, | 22 | 22 | getSavedComponentFilters, | 23 | 23 | getShowInlineWarningsAndErrors, | | 24 | + getHideConsoleLogsInStrictMode, | 24 | 25 | } from 'react-devtools-shared/src/utils'; | 25 | 26 | import {Server} from 'ws'; | 26 | 27 | import {join} from 'path'; | @@ -310,6 +311,9 @@ function startServer( | 310 | 311 | )}; | 311 | 312 | window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = ${JSON.stringify( | 312 | 313 | getShowInlineWarningsAndErrors(), | | 314 | + )}; | | 315 | + window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = ${JSON.stringify( | | 316 | + getHideConsoleLogsInStrictMode(), | 313 | 317 | )};`; | 314 | 318 |
| 315 | 319 | response.end( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.backend.js +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | const {resolve} = require('path'); | 2 | 2 | const {DefinePlugin} = require('webpack'); | 3 | 3 | const { | | 4 | + DARK_MODE_DIMMED_WARNING_COLOR, | | 5 | + DARK_MODE_DIMMED_ERROR_COLOR, | | 6 | + DARK_MODE_DIMMED_LOG_COLOR, | | 7 | + LIGHT_MODE_DIMMED_WARNING_COLOR, | | 8 | + LIGHT_MODE_DIMMED_ERROR_COLOR, | | 9 | + LIGHT_MODE_DIMMED_LOG_COLOR, | 4 | 10 | GITHUB_URL, | 5 | 11 | getVersionString, | 6 | 12 | } = require('react-devtools-extensions/utils'); | @@ -60,6 +66,12 @@ module.exports = { | 60 | 66 | 'process.env.DEVTOOLS_PACKAGE': `"react-devtools-core"`, | 61 | 67 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 62 | 68 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | | 69 | + 'process.env.DARK_MODE_DIMMED_WARNING_COLOR': `"${DARK_MODE_DIMMED_WARNING_COLOR}"`, | | 70 | + 'process.env.DARK_MODE_DIMMED_ERROR_COLOR': `"${DARK_MODE_DIMMED_ERROR_COLOR}"`, | | 71 | + 'process.env.DARK_MODE_DIMMED_LOG_COLOR': `"${DARK_MODE_DIMMED_LOG_COLOR}"`, | | 72 | + 'process.env.LIGHT_MODE_DIMMED_WARNING_COLOR': `"${LIGHT_MODE_DIMMED_WARNING_COLOR}"`, | | 73 | + 'process.env.LIGHT_MODE_DIMMED_ERROR_COLOR': `"${LIGHT_MODE_DIMMED_ERROR_COLOR}"`, | | 74 | + 'process.env.LIGHT_MODE_DIMMED_LOG_COLOR': `"${LIGHT_MODE_DIMMED_LOG_COLOR}"`, | 63 | 75 | }), | 64 | 76 | ], | 65 | 77 | optimization: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.standalone.js +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | const {resolve} = require('path'); | 2 | 2 | const {DefinePlugin} = require('webpack'); | 3 | 3 | const { | | 4 | + DARK_MODE_DIMMED_WARNING_COLOR, | | 5 | + DARK_MODE_DIMMED_ERROR_COLOR, | | 6 | + DARK_MODE_DIMMED_LOG_COLOR, | | 7 | + LIGHT_MODE_DIMMED_WARNING_COLOR, | | 8 | + LIGHT_MODE_DIMMED_ERROR_COLOR, | | 9 | + LIGHT_MODE_DIMMED_LOG_COLOR, | 4 | 10 | GITHUB_URL, | 5 | 11 | getVersionString, | 6 | 12 | } = require('react-devtools-extensions/utils'); | @@ -67,6 +73,12 @@ module.exports = { | 67 | 73 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 68 | 74 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 69 | 75 | 'process.env.NODE_ENV': `"${NODE_ENV}"`, | | 76 | + 'process.env.DARK_MODE_DIMMED_WARNING_COLOR': `"${DARK_MODE_DIMMED_WARNING_COLOR}"`, | | 77 | + 'process.env.DARK_MODE_DIMMED_ERROR_COLOR': `"${DARK_MODE_DIMMED_ERROR_COLOR}"`, | | 78 | + 'process.env.DARK_MODE_DIMMED_LOG_COLOR': `"${DARK_MODE_DIMMED_LOG_COLOR}"`, | | 79 | + 'process.env.LIGHT_MODE_DIMMED_WARNING_COLOR': `"${LIGHT_MODE_DIMMED_WARNING_COLOR}"`, | | 80 | + 'process.env.LIGHT_MODE_DIMMED_ERROR_COLOR': `"${LIGHT_MODE_DIMMED_ERROR_COLOR}"`, | | 81 | + 'process.env.LIGHT_MODE_DIMMED_LOG_COLOR': `"${LIGHT_MODE_DIMMED_LOG_COLOR}"`, | 70 | 82 | }), | 71 | 83 | ], | 72 | 84 | module: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/injectGlobalHook.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,6 +88,9 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') { | 88 | 88 |
| 89 | 89 | // Inject a __REACT_DEVTOOLS_GLOBAL_HOOK__ global for React to interact with. | 90 | 90 | // Only do this for HTML documents though, to avoid e.g. breaking syntax highlighting for XML docs. | | 91 | +// We need to inject this code because content scripts (ie injectGlobalHook.js) don't have access | | 92 | +// to the webpage's window, so in order to access front end settings | | 93 | +// and communicate with React, we must inject this code into the webpage | 91 | 94 | if ('text/html' === document.contentType) { | 92 | 95 | injectCode( | 93 | 96 | ';(' + | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/main.js +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { | 11 | 11 | getBreakOnConsoleErrors, | 12 | 12 | getSavedComponentFilters, | 13 | 13 | getShowInlineWarningsAndErrors, | | 14 | + getHideConsoleLogsInStrictMode, | 14 | 15 | } from 'react-devtools-shared/src/utils'; | 15 | 16 | import { | 16 | 17 | localStorageGetItem, | @@ -42,6 +43,12 @@ function syncSavedPreferences() { | 42 | 43 | )}; | 43 | 44 | window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = ${JSON.stringify( | 44 | 45 | getShowInlineWarningsAndErrors(), | | 46 | + )}; | | 47 | + window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = ${JSON.stringify( | | 48 | + getHideConsoleLogsInStrictMode(), | | 49 | + )}; | | 50 | + window.__REACT_DEVTOOLS_BROWSER_THEME__ = ${JSON.stringify( | | 51 | + getBrowserTheme(), | 45 | 52 | )};`, | 46 | 53 | ); | 47 | 54 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/utils.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | /* global chrome */ | 2 | 2 |
| | 3 | +import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools'; | | 4 | + | 3 | 5 | const IS_CHROME = navigator.userAgent.indexOf('Firefox') < 0; | 4 | 6 |
| 5 | 7 | export type BrowserName = 'Chrome' | 'Firefox'; | @@ -8,8 +10,6 @@ export function getBrowserName(): BrowserName { | 8 | 10 | return IS_CHROME ? 'Chrome' : 'Firefox'; | 9 | 11 | } | 10 | 12 |
| 11 | | -export type BrowserTheme = 'dark' | 'light'; | 12 | | - | 13 | 13 | export function getBrowserTheme(): BrowserTheme { | 14 | 14 | if (IS_CHROME) { | 15 | 15 | // chrome.devtools.panels added in Chrome 18. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/utils.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,13 @@ const {execSync} = require('child_process'); | 9 | 9 | const {readFileSync} = require('fs'); | 10 | 10 | const {resolve} = require('path'); | 11 | 11 |
| | 12 | +const DARK_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.5)'; | | 13 | +const DARK_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.5)'; | | 14 | +const DARK_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.5)'; | | 15 | +const LIGHT_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.75)'; | | 16 | +const LIGHT_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.75)'; | | 17 | +const LIGHT_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.75)'; | | 18 | + | 12 | 19 | const GITHUB_URL = 'https://github.com/facebook/react'; | 13 | 20 |
| 14 | 21 | function getGitCommit() { | @@ -36,6 +43,12 @@ function getVersionString() { | 36 | 43 | } | 37 | 44 |
| 38 | 45 | module.exports = { | | 46 | + DARK_MODE_DIMMED_WARNING_COLOR, | | 47 | + DARK_MODE_DIMMED_ERROR_COLOR, | | 48 | + DARK_MODE_DIMMED_LOG_COLOR, | | 49 | + LIGHT_MODE_DIMMED_WARNING_COLOR, | | 50 | + LIGHT_MODE_DIMMED_ERROR_COLOR, | | 51 | + LIGHT_MODE_DIMMED_LOG_COLOR, | 39 | 52 | GITHUB_URL, | 40 | 53 | getGitCommit, | 41 | 54 | getVersionString, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/webpack.backend.js +17-2Lines changed: 17 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | const {resolve} = require('path'); | 4 | 4 | const {DefinePlugin} = require('webpack'); | 5 | | -const {GITHUB_URL, getVersionString} = require('./utils'); | | 5 | +const { | | 6 | + DARK_MODE_DIMMED_WARNING_COLOR, | | 7 | + DARK_MODE_DIMMED_ERROR_COLOR, | | 8 | + DARK_MODE_DIMMED_LOG_COLOR, | | 9 | + LIGHT_MODE_DIMMED_WARNING_COLOR, | | 10 | + LIGHT_MODE_DIMMED_ERROR_COLOR, | | 11 | + LIGHT_MODE_DIMMED_LOG_COLOR, | | 12 | + GITHUB_URL, | | 13 | + getVersionString, | | 14 | +} = require('./utils'); | 6 | 15 | const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils'); | 7 | 16 |
| 8 | 17 | const NODE_ENV = process.env.NODE_ENV; | @@ -54,10 +63,16 @@ module.exports = { | 54 | 63 | new DefinePlugin({ | 55 | 64 | __DEV__: true, | 56 | 65 | __PROFILE__: false, | 57 | | - __EXPERIMENTAL__: true, | | 66 | + __DEV____DEV__: true, | 58 | 67 | 'process.env.DEVTOOLS_PACKAGE': `"react-devtools-extensions"`, | 59 | 68 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 60 | 69 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | | 70 | + 'process.env.DARK_MODE_DIMMED_WARNING_COLOR': `"${DARK_MODE_DIMMED_WARNING_COLOR}"`, | | 71 | + 'process.env.DARK_MODE_DIMMED_ERROR_COLOR': `"${DARK_MODE_DIMMED_ERROR_COLOR}"`, | | 72 | + 'process.env.DARK_MODE_DIMMED_LOG_COLOR': `"${DARK_MODE_DIMMED_LOG_COLOR}"`, | | 73 | + 'process.env.LIGHT_MODE_DIMMED_WARNING_COLOR': `"${LIGHT_MODE_DIMMED_WARNING_COLOR}"`, | | 74 | + 'process.env.LIGHT_MODE_DIMMED_ERROR_COLOR': `"${LIGHT_MODE_DIMMED_ERROR_COLOR}"`, | | 75 | + 'process.env.LIGHT_MODE_DIMMED_LOG_COLOR': `"${LIGHT_MODE_DIMMED_LOG_COLOR}"`, | 61 | 76 | }), | 62 | 77 | ], | 63 | 78 | module: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/webpack.config.js +16-1Lines changed: 16 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | const {resolve} = require('path'); | 4 | 4 | const {DefinePlugin} = require('webpack'); | 5 | | -const {GITHUB_URL, getVersionString} = require('./utils'); | | 5 | +const { | | 6 | + DARK_MODE_DIMMED_WARNING_COLOR, | | 7 | + DARK_MODE_DIMMED_ERROR_COLOR, | | 8 | + DARK_MODE_DIMMED_LOG_COLOR, | | 9 | + LIGHT_MODE_DIMMED_WARNING_COLOR, | | 10 | + LIGHT_MODE_DIMMED_ERROR_COLOR, | | 11 | + LIGHT_MODE_DIMMED_LOG_COLOR, | | 12 | + GITHUB_URL, | | 13 | + getVersionString, | | 14 | +} = require('./utils'); | 6 | 15 | const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils'); | 7 | 16 |
| 8 | 17 | const NODE_ENV = process.env.NODE_ENV; | @@ -76,6 +85,12 @@ module.exports = { | 76 | 85 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 77 | 86 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 78 | 87 | 'process.env.NODE_ENV': `"${NODE_ENV}"`, | | 88 | + 'process.env.DARK_MODE_DIMMED_WARNING_COLOR': `"${DARK_MODE_DIMMED_WARNING_COLOR}"`, | | 89 | + 'process.env.DARK_MODE_DIMMED_ERROR_COLOR': `"${DARK_MODE_DIMMED_ERROR_COLOR}"`, | | 90 | + 'process.env.DARK_MODE_DIMMED_LOG_COLOR': `"${DARK_MODE_DIMMED_LOG_COLOR}"`, | | 91 | + 'process.env.LIGHT_MODE_DIMMED_WARNING_COLOR': `"${LIGHT_MODE_DIMMED_WARNING_COLOR}"`, | | 92 | + 'process.env.LIGHT_MODE_DIMMED_ERROR_COLOR': `"${LIGHT_MODE_DIMMED_ERROR_COLOR}"`, | | 93 | + 'process.env.LIGHT_MODE_DIMMED_LOG_COLOR': `"${LIGHT_MODE_DIMMED_LOG_COLOR}"`, | 79 | 94 | }), | 80 | 95 | ], | 81 | 96 | module: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-inline/README.md +5-4Lines changed: 5 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -83,14 +83,15 @@ const { contentWindow } = iframe; | 83 | 83 | // This must be called before React is loaded into that frame. | 84 | 84 | initializeBackend(contentWindow); | 85 | 85 |
| 86 | | -// React application can be injected into <iframe> at any time now... | 87 | | -// Note that this would need to be done via <script> tag injection, | 88 | | -// as setting the src of the <iframe> would load a new page (without the injected backend). | 89 | | - | 90 | 86 | // Initialize DevTools UI to listen to the hook we just installed. | 91 | 87 | // This returns a React component we can render anywhere in the parent window. | | 88 | +// This also must be called before React is loaded into the iframe | 92 | 89 | const DevTools = initializeFrontend(contentWindow); | 93 | 90 |
| | 91 | +// React application can be injected into <iframe> at any time now... | | 92 | +// Note that this would need to be done via <script> tag injection, | | 93 | +// as setting the src of the <iframe> would load a new page (without the injected backend). | | 94 | + | 94 | 95 | // <DevTools /> interface can be rendered in the parent window at any time now... | 95 | 96 | // Be sure to use either ReactDOM.createRoot() | 96 | 97 | // or ReactDOM.createSyncRoot() to render this component. | |
|