Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update isCustomProps to accept "otherProps" #1194

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/components/grid/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,26 @@ export type CustomGridProps<T> = GridComponentProps<
> &
WithCustomGridProps<React.PropsWithChildren<T>>

type omittedProps =
| 'mobile'
| 'tablet'
| 'desktop'
| 'widescreen'
| 'mobileLg'
| 'tabletLg'
| 'desktopLg'
| 'children'
| 'className'
| 'row'
| 'col'
| 'gap'
| 'offset'

export function isCustomProps<T>(
props: DefaultGridProps | CustomGridProps<T>
): props is CustomGridProps<T> {
props:
| Omit<DefaultGridProps, omittedProps>
| Omit<CustomGridProps<T>, omittedProps>
): props is Omit<CustomGridProps<T>, omittedProps> {
return 'asCustom' in props
}

Expand Down Expand Up @@ -118,8 +135,8 @@ export function Grid<FCProps = DefaultGridProps>(

classes = classnames(classes, className)

if (isCustomProps(props)) {
const { asCustom, ...remainingProps } = props
if (isCustomProps(otherProps)) {
const { asCustom, ...remainingProps } = otherProps

const gridProps: FCProps = (remainingProps as unknown) as FCProps
return React.createElement(
Expand Down