From eb5dddb5ae633f9d4e47df3e8cbe467b418e97e7 Mon Sep 17 00:00:00 2001 From: jongomez Date: Sat, 14 Oct 2023 18:46:43 +0100 Subject: [PATCH] fix: remove null as any context initialization --- .../lsd-react/src/components/Button/Button.tsx | 2 +- .../ButtonGroup/ButtonGroup.context.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/lsd-react/src/components/Button/Button.tsx b/packages/lsd-react/src/components/Button/Button.tsx index 4e1d710..dfaaaed 100644 --- a/packages/lsd-react/src/components/Button/Button.tsx +++ b/packages/lsd-react/src/components/Button/Button.tsx @@ -27,7 +27,7 @@ export const Button: React.FC & { }) => { const context = useButtonGroupContext() const commonProps = useCommonProps(props) - const contextCommonProps = useCommonProps(context) + const contextCommonProps = useCommonProps(context || {}) const commonPropsClassName = commonProps.className || contextCommonProps.className diff --git a/packages/lsd-react/src/components/ButtonGroup/ButtonGroup.context.ts b/packages/lsd-react/src/components/ButtonGroup/ButtonGroup.context.ts index 1159968..8b2ff72 100644 --- a/packages/lsd-react/src/components/ButtonGroup/ButtonGroup.context.ts +++ b/packages/lsd-react/src/components/ButtonGroup/ButtonGroup.context.ts @@ -2,14 +2,15 @@ import React from 'react' import { ButtonProps } from '../Button/Button' import { CommonProps } from '../../utils/useCommonProps' -export type ButtonGroupContextType = CommonProps & { - size?: ButtonProps['size'] - variant?: ButtonProps['variant'] - disabled?: boolean -} +export type ButtonGroupContextType = + | (CommonProps & { + size?: ButtonProps['size'] + variant?: ButtonProps['variant'] + disabled?: boolean + }) + | null -export const ButtonGroupContext = React.createContext( - null as any, -) +export const ButtonGroupContext = + React.createContext(null) export const useButtonGroupContext = () => React.useContext(ButtonGroupContext)