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 context = useButtonGroupContext()
const commonProps = useCommonProps(props) const commonProps = useCommonProps(props)
const contextCommonProps = useCommonProps(context) const contextCommonProps = useCommonProps(context || {})
const commonPropsClassName = const commonPropsClassName =
commonProps.className || contextCommonProps.className commonProps.className || contextCommonProps.className

View File

@ -2,14 +2,15 @@ import React from 'react'
import { ButtonProps } from '../Button/Button' import { ButtonProps } from '../Button/Button'
import { CommonProps } from '../../utils/useCommonProps' import { CommonProps } from '../../utils/useCommonProps'
export type ButtonGroupContextType = CommonProps & { export type ButtonGroupContextType =
| (CommonProps & {
size?: ButtonProps['size'] size?: ButtonProps['size']
variant?: ButtonProps['variant'] variant?: ButtonProps['variant']
disabled?: boolean disabled?: boolean
} })
| null
export const ButtonGroupContext = React.createContext<ButtonGroupContextType>( export const ButtonGroupContext =
null as any, React.createContext<ButtonGroupContextType>(null)
)
export const useButtonGroupContext = () => React.useContext(ButtonGroupContext) export const useButtonGroupContext = () => React.useContext(ButtonGroupContext)