@@ -58,6 +58,10 @@ interface DevtoolsOptions {
58
58
* Defaults to 'aside'.
59
59
*/
60
60
containerElement ?: string | any
61
+ /**
62
+ * nonce for style element for CSP
63
+ */
64
+ styleNonce ?: string
61
65
}
62
66
63
67
interface DevtoolsPanelOptions {
@@ -73,6 +77,10 @@ interface DevtoolsPanelOptions {
73
77
* A boolean variable indicating whether the panel is open or closed
74
78
*/
75
79
isOpen ?: boolean
80
+ /**
81
+ * nonce for style element for CSP
82
+ */
83
+ styleNonce ?: string
76
84
/**
77
85
* A function that toggles the open and close state of the panel
78
86
*/
@@ -92,6 +100,7 @@ export function ReactQueryDevtools({
92
100
toggleButtonProps = { } ,
93
101
position = 'bottom-left' ,
94
102
containerElement : Container = 'aside' ,
103
+ styleNonce,
95
104
} : DevtoolsOptions ) : React . ReactElement | null {
96
105
const rootRef = React . useRef < HTMLDivElement > ( null )
97
106
const panelRef = React . useRef < HTMLDivElement > ( null )
@@ -229,6 +238,7 @@ export function ReactQueryDevtools({
229
238
< ThemeProvider theme = { theme } >
230
239
< ReactQueryDevtoolsPanel
231
240
ref = { panelRef as any }
241
+ styleNonce = { styleNonce }
232
242
{ ...otherPanelProps }
233
243
style = { {
234
244
position : 'fixed' ,
@@ -375,7 +385,13 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
375
385
HTMLDivElement ,
376
386
DevtoolsPanelOptions
377
387
> ( function ReactQueryDevtoolsPanel ( props , ref ) : React . ReactElement {
378
- const { isOpen = true , setIsOpen, handleDragStart, ...panelProps } = props
388
+ const {
389
+ isOpen = true ,
390
+ styleNonce,
391
+ setIsOpen,
392
+ handleDragStart,
393
+ ...panelProps
394
+ } = props
379
395
380
396
const queryClient = useQueryClient ( )
381
397
const queryCache = queryClient . getQueryCache ( )
@@ -467,6 +483,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
467
483
{ ...panelProps }
468
484
>
469
485
< style
486
+ nonce = { styleNonce }
470
487
dangerouslySetInnerHTML = { {
471
488
__html : `
472
489
.ReactQueryDevtoolsPanel * {
0 commit comments