/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
tools/react-19/react-jsx-runtime.js
42 строки
1 KB
Jarda Snajdr
React 19 patch: log warnings when polyfills are hit (#79624)
29 июн 2026, 15:55
Не верифицирован
29 июн 2026, 15:55
463e4a9
Код
Авторство
О чём код?
const jsxRuntime = require( 'react/jsx-runtime' ); const { warnCompat } = require( './warn-compat' ); function applyDefaultProps( type, config ) { if ( ! type || ! type.defaultProps ) { return config; } warnCompat( 'jsx-default-props', '`defaultProps` on function components was removed in React 19 and is emulated by a compatibility polyfill. Use default parameters instead.' ); const defaultProps = type.defaultProps; let props = config; for ( const propName in defaultProps ) { if ( props[ propName ] === undefined ) { // Clone lazily so the caller's config object is never mutated. if ( props === config ) { props = { ...config }; } props[ propName ] = defaultProps[ propName ]; } } return props; } function jsx( type, config, maybeKey ) { return jsxRuntime.jsx( type, applyDefaultProps( type, config ), maybeKey ); } function jsxs( type, config, maybeKey ) { return jsxRuntime.jsxs( type, applyDefaultProps( type, config ), maybeKey ); } module.exports = { ...jsxRuntime, jsx, jsxs, };