mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 01:45:15 +00:00
25 lines
617 B
JavaScript
25 lines
617 B
JavaScript
|
/* eslint-disable no-restricted-syntax */
|
||
|
export default function getThemeProps(params) {
|
||
|
const {
|
||
|
theme,
|
||
|
name,
|
||
|
props
|
||
|
} = params;
|
||
|
|
||
|
if (!theme || !theme.props || !theme.props[name]) {
|
||
|
return props;
|
||
|
} // Resolve default props, code borrow from React source.
|
||
|
// https://github.com/facebook/react/blob/15a8f031838a553e41c0b66eb1bcf1da8448104d/packages/react/src/ReactElement.js#L221
|
||
|
|
||
|
|
||
|
const defaultProps = theme.props[name];
|
||
|
let propName;
|
||
|
|
||
|
for (propName in defaultProps) {
|
||
|
if (props[propName] === undefined) {
|
||
|
props[propName] = defaultProps[propName];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return props;
|
||
|
}
|