/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/preact/component/wrapper.js
39 строк
903 B
Jake Fried
typecheck: src/preact/components (#37463)
04 фев 2022, 23:59
Не верифицирован
04 фев 2022, 23:59
2004c91
Код
Авторство
О чём код?
import * as Preact from '#preact'; import {forwardRef} from '#preact/compat'; import {propName} from '#preact/utils'; /** * The wrapper component provides the canonical wrapper for components whose * size depends on the children. This is often the opposite of the * `ContainWrapper`. * @param {import('./types').WrapperComponentProps} props * @param {import('preact').RefObject<Element>} ref * @return {import('preact').VNode} */ function WrapperWithRef( { as: Comp = 'div', children, 'style': style, wrapperClassName, wrapperStyle, [propName('class')]: className, ...rest }, ref ) { return ( <Comp {...rest} ref={ref} class={`${className || ''} ${wrapperClassName || ''}`.trim() || null} style={{...style, ...wrapperStyle}} > {children} </Comp> ); } const Wrapper = forwardRef(WrapperWithRef); export {Wrapper};