0.2.4 • Published 2 years ago

@colebemis/react-slots v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-slots

npm

Install

npm install @colebemis/react-slots

Usage

import { useSlots } from "@colebemis/react-slots";

function Layout({ children }: { children?: React.ReactNode }) {
  const [slots, rest] = useSlots(children, {
    header: Header,
    footer: Footer,
  });

  return (
    <div>
      {slots.header}
      <main>{rest}</main>
      {slots.footer}
    </div>
  );
}

function Header() {
  return <header>Header</header>;
}

function Footer() {
  return <footer>Footer</footer>;
}

function App() {
  return (
    <Layout>
      <Header />
      <h1>Hello, slots!</h1>
      <Footer />
    </Layout>
  );
}
0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago