MCPcopy Create free account
hub / github.com/ampproject/amphtml / WrapperWithRef

Function WrapperWithRef

src/preact/component/wrapper.js:13–35  ·  view source on GitHub ↗

* 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 } ref * @return {import('preact

(
  {
    as: Comp = 'div',
    children,
    'style': style,
    wrapperClassName,
    wrapperStyle,
    [propName('class')]: className,
    ...rest
  },
  ref
)

Source from the content-addressed store, hash-verified

11 * @return {import('preact').VNode}
12 */
13function WrapperWithRef(
14 {
15 as: Comp = 'div',
16 children,
17 'style': style,
18 wrapperClassName,
19 wrapperStyle,
20 [propName('class')]: className,
21 ...rest
22 },
23 ref
24) {
25 return (
26 <Comp
27 {...rest}
28 ref={ref}
29 class={`${className || ''} ${wrapperClassName || ''}`.trim() || null}
30 style={{...style, ...wrapperStyle}}
31 >
32 {children}
33 </Comp>
34 );
35}
36
37const Wrapper = forwardRef(WrapperWithRef);
38

Callers

nothing calls this directly

Calls 1

propNameFunction · 0.90

Tested by

no test coverage detected