UNPKG

@zemd/react-slottable

Version:

A lightweight concept to customize subcomponents in React

2 lines (1 loc) 476 B
var d=Object.defineProperty;var o=(t,r)=>d(t,"name",{value:r,configurable:!0});import e from"react";var u=o(({children:t})=>e.createElement(e.Fragment,null,t),"SlotFragment");u.displayName="@zemd/react-slottable/SlotFragment";function S(t,r,{slot:n,...s}={}){let{slots:l,slotProps:m}=r,p=e.useMemo(()=>l?.[t]??n??u,[t,l,n]);return e.useMemo(()=>o(c=>{let a={...c,...m?.[t],...s};return e.createElement(p,a)},"WrappedComponent"),[p,t,m,s])}o(S,"useSlot");export{S as useSlot};