Skip to content

Commit

Permalink
fix(componentProps): 🐛 proper solution for all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Jan 4, 2022
1 parent 2e2aa68 commit e33161f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/checkbox-group/CheckboxGroupWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const useCheckboxGroupContextWrapper = createHook<

export const CheckboxGroupWrapper = createComponent({
as: "div",
memo: true,
useHook: useCheckboxGroupContextWrapper,
useCreateElement: (type, props, children) => {
useWarning(
Expand Down
1 change: 1 addition & 0 deletions src/tooltip/SliderTooltipReference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@ export const useSliderTooltipReference = createHook<

export const SliderTooltipReference = createComponent({
as: "div",
memo: true,
useHook: useSliderTooltipReference,
});
16 changes: 10 additions & 6 deletions src/utils/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,22 @@ export const getComponentProps = <T, P>(

if (validChildren.length > 0) {
validChildren.forEach(function (child) {
// For only React Element
// @ts-ignore
if (componentMaps[child.type.displayName]) {
if (componentMaps[child?.type]) {
// @ts-ignore
componentProps[componentMaps[child.type.displayName]] = child.props; // @ts-ignore
} else if (componentMaps[child.type.type.displayName]) {
componentProps[componentMaps[child?.displayName]] = child.props;
// For Forwarded Ref with React Element
// @ts-ignore
componentProps[componentMaps[child.type.type.displayName]] = // @ts-ignore
} else if (componentMaps[child?.type?.render?.displayName]) {
// @ts-ignore
componentProps[componentMaps[child?.type?.render?.displayName]] =
child.props;
// For Memoised Forwarded Ref with React Element
// @ts-ignore
} else if (componentMaps[child.type.type.render.displayName]) {
} else if (componentMaps[child?.type?.type?.render?.displayName]) {
// @ts-ignore
componentProps[componentMaps[child.type.type.render.displayName]] = // @ts-ignore
componentProps[componentMaps[child?.type?.type?.render?.displayName]] =
child.props;
} else {
finalChildren.push(child);
Expand Down

1 comment on commit e33161f

@vercel
Copy link

@vercel vercel bot commented on e33161f Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.