@material-ui/unstyled
Version:
Unstyled React components with which to implement custom design systems.
19 lines (17 loc) • 676 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import isHostComponent from './isHostComponent';
/**
* Appends the ownerState object to the props, merging with the existing one if necessary.
*
* @param elementType Type of the element that owns the `existingProps`. If the element is a DOM node, `ownerState` are not applied.
* @param existingProps Props of the element.
* @param ownerState
*/
export default function appendOwnerState(elementType, existingProps, ownerState) {
if (isHostComponent(elementType)) {
return existingProps;
}
return _extends({}, existingProps, {
ownerState: _extends({}, existingProps.ownerState, ownerState)
});
}