react/packages/react-devtools-shared/src
Luna Ruan d63cd97245
don't stringify objects for console log second render (#24373)
Fixes #24302 based on #24306.
---

The current implementation for strict mode double logging stringiness and dims the second log. However, because we stringify everything, including objects, this causes objects to be logged as `[object Object]` etc.

This PR creates a new function that formats console log arguments with a specified style. It does this by:
1. The first param is a string that contains %c: Bail out and return the args without modifying the styles. We don't want to affect styles that the developer deliberately set.
2. The first param is a string that doesn't contain %c but contains string formatting: `[`%c${args[0]}`, style, ...args.slice(1)]` Note: we assume that the string formatting that the developer uses is correct.
3. The first param is a string that doesn't contain string formatting OR is not a string: Create a formatting string where:
   -  boolean, string, symbol -> %s
   -  number -> %f OR %i depending on if it's an int or float
   -  default -> %o
---
Co-authored-by: Billy Janitsch <billy@kensho.com>
2022-04-14 11:30:04 -05:00
..
__tests__ don't stringify objects for console log second render (#24373) 2022-04-14 11:30:04 -05:00
backend don't stringify objects for console log second render (#24373) 2022-04-14 11:30:04 -05:00
config StyleX plug-in for resolving atomic styles to values for props.xstyle (#22808) 2021-12-07 20:04:12 -05:00
devtools Attach DevTools Tree keyboard events to the Tree container (not the document) (#24164) 2022-03-25 12:41:13 -04:00
hooks Correct typing errors detected in several files (#22965) 2022-01-04 10:30:07 -05:00
node_modules/react-window Code mod import * as React from 'react' in react-window (#18105) 2020-02-21 23:20:17 -08:00
Logger.js [DevTools] Log errors occurring or reported to the frontend (#22948) 2021-12-13 11:38:45 -05:00
PerformanceLoggingUtils.js Clear performance marks after measuring (#22345) 2021-09-17 10:46:42 -04:00
TimeoutError.js Show different error boundary UI for timeouts than normal errors (#22483) 2021-10-01 15:03:36 -04:00
UnsupportedBridgeOperationError.js Store throws a specific Error type (UnsupportedBridgeOperationError) (#24147) 2022-03-23 17:04:54 -04:00
backendAPI.js StyleX plug-in for resolving atomic styles to values for props.xstyle (#22808) 2021-12-07 20:04:12 -05:00
bridge.js Disable unsupported Bridge protocol version dialog and add workaround for old protocol operations format (#24093) 2022-03-15 13:48:26 -04:00
constants.js DevTools: Timeline profiler refactor 2022-01-28 13:09:28 -05:00
dynamicImportCache.js Rename (some) "scheduling profiler" references to "timeline" (#22690) 2021-11-03 15:10:29 -04:00
events.js Enable prefer-const lint rules (#18451) 2020-04-01 12:35:52 -07:00
hook.js don't stringify objects for console log second render (#24373) 2022-04-14 11:30:04 -05:00
hookNamesCache.js Rename (some) "scheduling profiler" references to "timeline" (#22690) 2021-11-03 15:10:29 -04:00
hydration.js DevTooks: Don't dehydrate hook source fileNames (#21814) 2021-07-07 14:24:17 -04:00
inspectedElementCache.js Rename (some) "scheduling profiler" references to "timeline" (#22690) 2021-11-03 15:10:29 -04:00
inspectedElementMutableSource.js Correct typing errors detected in several files (#22965) 2022-01-04 10:30:07 -05:00
isArray.js Add isArray in devTools utils (#22438) 2021-09-27 17:17:30 -04:00
registerDevToolsEventLogger.js DevTools: Log version in internal logger (#22825) 2021-11-30 10:48:46 -05:00
storage.js Added FB copyright header 2019-08-27 10:54:01 -07:00
types.js add <TracingMarker> component boilerplate (#23275) 2022-02-11 08:42:55 -08:00
utils.js add <TracingMarker> component boilerplate (#23275) 2022-02-11 08:42:55 -08:00