All Projects → ytiurin → react-hook-layout

ytiurin / react-hook-layout

Licence: ISC license
Layouts in React.

Programming Languages

javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to react-hook-layout

formalizer
React hooks based form validation made for humans.
Stars: ✭ 12 (-25%)
Mutual labels:  hook, react-hooks
use-route-as-state
Use React Router route and query string as component state
Stars: ✭ 37 (+131.25%)
Mutual labels:  hook, react-hooks
window-scroll-position
React hook for Window scroll position
Stars: ✭ 81 (+406.25%)
Mutual labels:  hook, react-hooks
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (+1000%)
Mutual labels:  hook, react-hooks
react-hook-videojs
Easy React integration of Video.js using hooks.
Stars: ✭ 37 (+131.25%)
Mutual labels:  hook, react-hooks
use-dencrypt-effect
⚛ A custom React hook generating crypting text effect.
Stars: ✭ 39 (+143.75%)
Mutual labels:  hook, react-hooks
Fre
👻 Tiny Footprint Concurrent UI library for Fiber.
Stars: ✭ 3,195 (+19868.75%)
Mutual labels:  hook, react-hooks
react-use-countdown
React hook for countdown state.
Stars: ✭ 19 (+18.75%)
Mutual labels:  hook, react-hooks
usehooks-ts
React hook library, ready to use, written in Typescript.
Stars: ✭ 2,873 (+17856.25%)
Mutual labels:  hook, react-hooks
web
React hooks done right, for browser and SSR.
Stars: ✭ 940 (+5775%)
Mutual labels:  hook, react-hooks
react-ui-hooks
🧩Simple repository of React hooks for building UI components
Stars: ✭ 20 (+25%)
Mutual labels:  hook, react-hooks
ReSift
A state management library for data fetches in React
Stars: ✭ 39 (+143.75%)
Mutual labels:  hook, react-hooks
react-use-hotkeys
React hook for creating simple keyboard shortcuts
Stars: ✭ 74 (+362.5%)
Mutual labels:  hook, react-hooks
react-click-away-listener
🐾 Tiny React Click Away Listener built with React Hooks
Stars: ✭ 131 (+718.75%)
Mutual labels:  react-hooks
table-layout
Styleable plain-text table generator. Useful for formatting console output.
Stars: ✭ 18 (+12.5%)
Mutual labels:  layout
transition-hook
☄️ An extremely light-weight react transition animation hook which is simpler and easier to use than react-transition-group
Stars: ✭ 250 (+1462.5%)
Mutual labels:  hook
svelte-bricks
Naive Svelte Masonry component without column balancing (ragged columns at the bottom)
Stars: ✭ 22 (+37.5%)
Mutual labels:  layout
react-hooks-sse
Subscribe to an SSE endpoint with React Hooks
Stars: ✭ 60 (+275%)
Mutual labels:  react-hooks
react-hubspot
A collection of React hooks for interacting with Hubspot APIs
Stars: ✭ 20 (+25%)
Mutual labels:  react-hooks
CSS-Grid
CSS Grid 레이아웃 모듈 Level 1
Stars: ✭ 21 (+31.25%)
Mutual labels:  layout

react-hook-layout

Demo page

This hook is a variation of the approach, described on Composition vs Inheritance documentation page.

Layout is now a separate component, and can be applied on different pages. Also, it's easy to switch layouts in runtime.

Install

npm i react-hook-layout

Usage

  1. Layout component look like this:
import { useSlots } from "react-hook-layout";

export const MyLayout = () => {
  const { A, B } = useSlots("A", "B");

  return (
    <>
      <article>{A}</article>
      <footer>{B}</footer>
    </>
  );
};
  1. Page component using layout:
import { defineSlots, useLayout } from "react-hook-layout";
import { MyLayout } from "./MyLayout";

const { A, B } = defineSlots("A", "B");

const MyPage = () => {
  const Layout = useLayout(MyLayout);

  return (
    <Layout>
      <A>My article</A>
      <B>Author by Me</B>
    </Layout>
  );
};

Page will render to:

<article>My article</article>
<footer>Author by Me</footer>

Examples

Check examples on the demo page

or

Run storybook localy:

git clone https://github.com/ytiurin/react-hook-layout.git
cd react-hook-layout/storybook
npm run storybook
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].