/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-styled-engine-sc/src/StyledEngineProvider/StyledEngineProvider.ts
35 строк
1 KB
Jan Potoms
[code-infra] Convert @mui/styled-engine-sc to TypeScript (#48577)
28 май 2026, 12:36
Не верифицирован
28 май 2026, 12:36
4a664f4
Код
Авторство
О чём код?
import type * as React from 'react'; import PropTypes from 'prop-types'; export interface StyledEngineProviderProps { children?: React.ReactNode; injectFirst?: boolean | undefined; } export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element { 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 as React.JSX.Element; } (StyledEngineProvider as any).propTypes /* remove-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, };