@nooks_seo/use-tab
v1.0.0
Published
React Hook to easily manage tab navigation by controlling active content.
Readme
@nooks_seo/use-tab
React Hook to easily manage tab navigation by controlling active content.
📦 설치
npm install @nooks_seo/use-tab
# 또는
yarn add @nooks_seo/use-tab사용 방법
import React from "react";
import { useTabs } from "@nooks_seo/use-tab";
const content = [
{
tab: "Section 1",
content: "I'm the content of the Section 1"
},
{
tab: "Section 2",
content: "I'm the content of the Section 2"
}
];
function App() {
const { currentItem, changeItem } = useTabs(0, content);
return (
<div>
{content.map((section, index) => (
<button key={index} onClick={() => changeItem(index)}>
{section.tab}
</button>
))}
<div>{currentItem.content}</div>
</div>
);
}
export default App;