1.0.0 • Published 4 years ago

@custom_react_hook/use-tabs v1.0.0

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

@custom_react_hook/use-tabs

React Hook to change your tab.

Installation

yarn

yarn add @custom_react_hook/use-tabs

npm

npm i @custom_react_hook/use-tabs

Usage

import React from "react";
import useTabs from "@custom_react_hook/use-tabs";
function App() {
  const myTabs = ["apple","banana","pear"];
  const { currentItem, changeItem } = useTabs(myTabs);
  return (
    { myTabs.map((content,index) => (
      <button onClick={() => changeItem(index)}>
        { content }
      </button>
    ))}
    <div>{ currentItem }</div>
  );
}

Arguments

ArgumentTypeDescriptionRequired
allTabsArrayan Array containing allTabsyes
initialTabNumberinitial tab's index (default = 0)no