fix: remove null as any context initialization

This commit is contained in:
jongomez 2023-10-14 18:46:43 +01:00 committed by Jon
parent c49364fa71
commit eb5dddb5ae
2 changed files with 10 additions and 9 deletions

View File

@ -27,7 +27,7 @@ export const Button: React.FC<ButtonProps> & {
}) => {
const context = useButtonGroupContext()
const commonProps = useCommonProps(props)
const contextCommonProps = useCommonProps(context)
const contextCommonProps = useCommonProps(context || {})
const commonPropsClassName =
commonProps.className || contextCommonProps.className

View File

@ -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<ButtonGroupContextType>(
null as any,
)
export const ButtonGroupContext =
React.createContext<ButtonGroupContextType>(null)
export const useButtonGroupContext = () => React.useContext(ButtonGroupContext)