{"id":13450425,"url":"https://github.com/ytiurin/react-hook-layout","last_synced_at":"2025-08-22T13:37:33.429Z","repository":{"id":40724400,"uuid":"252834090","full_name":"ytiurin/react-hook-layout","owner":"ytiurin","description":"Layouts in React.","archived":false,"fork":false,"pushed_at":"2023-01-06T02:48:09.000Z","size":3166,"stargazers_count":18,"open_issues_count":18,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T22:54:13.426Z","etag":null,"topics":["hook","layout","react","react-hooks"],"latest_commit_sha":null,"homepage":"https://ytiurin.github.io/react-hook-layout/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ytiurin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-03T20:29:40.000Z","updated_at":"2023-05-29T03:27:59.000Z","dependencies_parsed_at":"2023-02-05T03:46:03.960Z","dependency_job_id":null,"html_url":"https://github.com/ytiurin/react-hook-layout","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytiurin%2Freact-hook-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytiurin%2Freact-hook-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytiurin%2Freact-hook-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytiurin%2Freact-hook-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ytiurin","download_url":"https://codeload.github.com/ytiurin/react-hook-layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253160814,"owners_count":21863625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hook","layout","react","react-hooks"],"created_at":"2024-07-31T07:00:34.530Z","updated_at":"2025-05-08T22:54:19.840Z","avatar_url":"https://github.com/ytiurin.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# react-hook-layout\n\n[Demo page][demo]\n\nThis hook is a variation of the approach, described on [Composition vs Inheritance](https://reactjs.org/docs/composition-vs-inheritance.html \"Composition vs Inheritance\") documentation page.\n\nLayout is now a separate component, and can be applied on different pages. Also, it's easy to switch layouts in runtime.\n\n## Install\n\n```\nnpm i react-hook-layout\n```\n\n## Usage\n\n1. Layout component look like this:\n\n```javascript\nimport { useSlots } from \"react-hook-layout\";\n\nexport const MyLayout = () =\u003e {\n  const { A, B } = useSlots(\"A\", \"B\");\n\n  return (\n    \u003c\u003e\n      \u003carticle\u003e{A}\u003c/article\u003e\n      \u003cfooter\u003e{B}\u003c/footer\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n2. Page component using layout:\n\n```javascript\nimport { defineSlots, useLayout } from \"react-hook-layout\";\nimport { MyLayout } from \"./MyLayout\";\n\nconst { A, B } = defineSlots(\"A\", \"B\");\n\nconst MyPage = () =\u003e {\n  const Layout = useLayout(MyLayout);\n\n  return (\n    \u003cLayout\u003e\n      \u003cA\u003eMy article\u003c/A\u003e\n      \u003cB\u003eAuthor by Me\u003c/B\u003e\n    \u003c/Layout\u003e\n  );\n};\n```\n\nPage will render to:\n\n```html\n\u003carticle\u003eMy article\u003c/article\u003e\n\u003cfooter\u003eAuthor by Me\u003c/footer\u003e\n```\n\n## Examples\n\nCheck examples on the [demo page][demo]\n\n_or_\n\nRun storybook localy:\n\n```\ngit clone https://github.com/ytiurin/react-hook-layout.git\ncd react-hook-layout/storybook\nnpm run storybook\n```\n\n[demo]: https://ytiurin.github.io/react-hook-layout/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytiurin%2Freact-hook-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fytiurin%2Freact-hook-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytiurin%2Freact-hook-layout/lists"}