Skip to content
Permalink
685c72dfaf
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

29 lines (25 sloc) 853 Bytes
import PropTypes from 'prop-types';
export default function StyledEngineProvider(props) {
const { injectFirst, children } = props;
if (injectFirst && typeof window !== 'undefined') {
const head = document.head;
if (!head.querySelector('[data-styled="active"]')) {
const injectFirstNode = document.createElement('style');
injectFirstNode.setAttribute('data-styled', 'active');
head.insertBefore(injectFirstNode, head.firstChild);
}
}
return children;
}
StyledEngineProvider.propTypes = {
/**
* Your component tree.
*/
children: PropTypes.node,
/**
* By default, the styles are injected last in the <head> element of the page.
* As a result, they gain more specificity than any other style sheet.
* If you want to override MUI's styles, set this prop.
*/
injectFirst: PropTypes.bool,
};