From 09c8959e3bfcdb2f3702f33aa992410513c017a3 Mon Sep 17 00:00:00 2001 From: Peter Hellstrand Date: Tue, 20 Aug 2024 14:40:50 +0200 Subject: [PATCH 1/3] chore(ffe-accordion-react): remove unused dep --- packages/ffe-accordion-react/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ffe-accordion-react/package.json b/packages/ffe-accordion-react/package.json index f19b62ae4a..7e321460d1 100644 --- a/packages/ffe-accordion-react/package.json +++ b/packages/ffe-accordion-react/package.json @@ -28,7 +28,6 @@ "@sb1/ffe-accordion": "^10.0.30", "@sb1/ffe-collapse-react": "^5.0.5", "@sb1/ffe-icons-react": "^11.0.2", - "@types/uuid": "^9.0.0", "classnames": "^2.3.1" }, "devDependencies": { From 7c4a0eae8a24cf61d9e8d8fb9487d1cbe1cadd8e Mon Sep 17 00:00:00 2001 From: Peter Hellstrand Date: Tue, 20 Aug 2024 14:41:33 +0200 Subject: [PATCH 2/3] fix(ffe-form-react): fjerner uuid og bruker useId --- packages/ffe-form-react/src/ToggleSwitch.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/ffe-form-react/src/ToggleSwitch.tsx b/packages/ffe-form-react/src/ToggleSwitch.tsx index 7111ebd2e6..d512a333f0 100644 --- a/packages/ffe-form-react/src/ToggleSwitch.tsx +++ b/packages/ffe-form-react/src/ToggleSwitch.tsx @@ -1,5 +1,4 @@ -import React, { useRef } from 'react'; -import { v4 as uuidv4 } from 'uuid'; +import React, { useId } from 'react'; import classNames from 'classnames'; import i18n from './i18n/i18n'; @@ -26,13 +25,15 @@ export const ToggleSwitch: React.FC = ({ hideOnOff, onText, offText, - id, + id: providedId, value = 'on', locale = 'nb', checked, ...rest }) => { - const generatedId = useRef(id ?? `toggle-${uuidv4()}`).current; + const generatedId = useId(); + + const id = providedId ?? generatedId; const text = i18n[locale]; @@ -47,12 +48,12 @@ export const ToggleSwitch: React.FC = ({ -