Skip to content

Commit

Permalink
Sebastian's review
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Jan 14, 2021
1 parent 747801f commit 6e25d37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/material-ui-utils/src/requirePropFactory.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type Component = (arg: any) => any & { propTypes?: object };
import * as React from 'react';

export default function requirePropFactory(componentNameInError: string, Component?: Component): any;
export default function requirePropFactory(componentNameInError: string, Component?: React.ComponentType): any;
11 changes: 5 additions & 6 deletions packages/material-ui-utils/src/requirePropFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export default function requirePropFactory(componentNameInError, Component) {
) => {
const propFullNameSafe = propFullName || propName;

const defaultPropType = Component?.propTypes?.[propFullNameSafe];
let defaultPropTypeVal = null;
const defaultTypeChecker = Component?.propTypes?.[propFullNameSafe];
let defaultTypeCheckerResult = null;

if(defaultPropType) {
console.log("Default prop type existed");
defaultPropTypeVal = defaultPropType(props, propName, componentName, location, propFullName)
if(defaultTypeChecker) {
defaultTypeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName)
}

if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
Expand All @@ -27,7 +26,7 @@ export default function requirePropFactory(componentNameInError, Component) {
);
}

return defaultPropTypeVal;
return defaultTypeCheckerResult;
};
return requireProp;
}

0 comments on commit 6e25d37

Please sign in to comment.