From eb4c1ae581a7e0390995598b2698d88d397d1b23 Mon Sep 17 00:00:00 2001 From: melloware Date: Wed, 12 Jul 2023 17:38:04 -0400 Subject: [PATCH] #4602: Add NONCE to inline style --- components/lib/hooks/useStyle.js | 4 ++-- components/lib/utils/utils.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/lib/hooks/useStyle.js b/components/lib/hooks/useStyle.js index 5d70466892..462a206f64 100644 --- a/components/lib/hooks/useStyle.js +++ b/components/lib/hooks/useStyle.js @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react'; +import { useContext, useEffect, useRef, useState } from 'react'; import PrimeReact, { PrimeReactContext } from '../api/Api'; import { DomHandler } from '../utils/Utils'; @@ -7,7 +7,7 @@ let _id = 0; export const useStyle = (css, options = {}) => { const [isLoaded, setIsLoaded] = useState(false); const styleRef = useRef(null); - const context = React.useContext(PrimeReactContext); + const context = useContext(PrimeReactContext); const defaultDocument = DomHandler.isClient() ? window.document : undefined; const { document = defaultDocument, immediate = true, manual = false, name = `style_${++_id}`, id = undefined, media = undefined } = options; diff --git a/components/lib/utils/utils.d.ts b/components/lib/utils/utils.d.ts index 282cfefc6f..c90321c1c7 100644 --- a/components/lib/utils/utils.d.ts +++ b/components/lib/utils/utils.d.ts @@ -76,8 +76,8 @@ export declare class DomHandler { static applyStyle(el: HTMLElement, style: any): void; static exportCSV(csv: any, filename: string): void; static saveAs(file: { name: string; url: any }): boolean; - static createInlineStyle(nonce: string): HTMLElement; - static removeInlineStyle(styleElement: HTMLElement): HTMLElement | null; + static createInlineStyle(nonce?: string): HTMLStyleElement; + static removeInlineStyle(styleElement: HTMLStyleElement): HTMLStyleElement | null; static getTargetElement(target: any): HTMLElement | null; }