Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
30 lines
853 B
JavaScript
30 lines
853 B
JavaScript
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,
|
|
};
|