Skip to content

Commit 045b967

Browse files
author
Karl Brightman
committed
Ensure missing proptypes do not throw errors
1 parent aa3fbee commit 045b967

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/rsg-components/Props/Props.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export let Code = ({ className = '', children }) => {
1111
return <code className={sMarkdown.code + ' ' + className}>{children}</code>;
1212
};
1313

14+
export let UnknownPropType = () => <span>unknown</span>
15+
1416
export function unquote(string) {
1517
return trim(string, '"\'');
1618
}
@@ -37,7 +39,10 @@ export default class Props extends Component {
3739
}
3840

3941
renderType(type) {
42+
if (!type) return 'unknown'
43+
4044
let { name } = type;
45+
4146
switch (name) {
4247
case 'arrayOf':
4348
return `${type.value.name}[]`;
@@ -76,7 +81,10 @@ export default class Props extends Component {
7681
}
7782

7883
renderExtra(prop) {
79-
switch (getType(prop).name) {
84+
const type = getType(prop)
85+
if (!type) return null
86+
87+
switch (type.name) {
8088
case 'enum':
8189
return this.renderEnum(prop);
8290
case 'union':

0 commit comments

Comments
 (0)