Skip to content

Commit 1a1012b

Browse files
mc-petryTkDodo
andauthored
fix(react-query-devtools): Fix JSON formatting in detail view. (#4418)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
1 parent 188453f commit 1a1012b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/react-query-devtools/src/devtools.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getResizeHandleStyle,
2323
getSidedProp,
2424
defaultPanelSize,
25+
displayValue,
2526
} from './utils'
2627
import type { Corner, Side } from './utils'
2728
import {
@@ -846,7 +847,7 @@ const ActiveQuery = ({
846847
overflow: 'auto',
847848
}}
848849
>
849-
{JSON.stringify(activeQuery.queryKey, null, 2)}
850+
{displayValue(activeQuery.queryKey, true)}
850851
</pre>
851852
</Code>
852853
<span

packages/react-query-devtools/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ export function useIsMounted() {
117117
/**
118118
* Displays a string regardless the type of the data
119119
* @param {unknown} value Value to be stringified
120+
* @param {boolean} beautify Formats json to multiline
120121
*/
121-
export const displayValue = (value: unknown) => {
122+
export const displayValue = (value: unknown, beautify: boolean = false) => {
122123
const { json } = SuperJSON.serialize(value)
123124

124-
return JSON.stringify(json)
125+
return JSON.stringify(json, null, beautify ? 2 : undefined)
125126
}
126127

127128
// Sorting functions

0 commit comments

Comments
 (0)