@ignition-concept/react-forward-slot
v0.1.0
Published
an utils for forward base component prop forward to child main slot tag
Downloads
1
Maintainers
Keywords
Readme
React Forward Children Slot
Installation
# for npm
npm i @ignition-concept/react-forward-slot
# for yarn
yarn add @ignition-concept/react-forward-slot
# for pnpm
pnpm install @ignition-concept/react-forward-slot
Usage
import { Slot } from "@ignition-concept/react-forward-slot";
/**
*
* Note: `forwardAs` attributes just for type definition it doesn't affect you
* component
*
**/
export function Expose({ children, ...props }) {
return (
<Slot
forwardAs="button"
onClick={function () {
return console.log("hello world Expose");
}}
>
<button {...props}>Hello World</button>
</Slot>
);
}
export function Exposed() {
return (
<Slot
forwardAs={Expose}
onClick={function () {
return console.log("hello world Exposed");
}}
>
<Expose>Hello World</Expose>
</Slot>
);
}
Note: internal usage only*
* use at your own risk