components_get-components.js
/**
* @module getComponents
* @description Allows you to get override components and styles for a given react component.
*
* @since 1.2.13
*
* @param {object} defaultComponents The default components to render.
* @param {object} overrides Override components.
*
* @return {{}} The final components to render.
*/
export default function getComponents( defaultComponents, overrides ) {
return Object.keys( defaultComponents ).reduce( ( acc, name ) => {
const override = overrides[ name ] || {};
acc[ name ] = {
component: override.component || defaultComponents[ name ],
props: { $style: override.style, ...override.props },
};
return acc;
}, {} );
}