1.0.0 • Published 2 years ago

phtabs v1.0.0

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

React Chrome Tabs

Usage

  1. use hooks

import { useChromeTabs } from "react-chrome-tabs";

function Example() {
  const [tabs, setTabs] = useState([]);
  const { ChromeTabs, addTab, updateTab, removeTab } = useChromeTabs({
    onTabActivated: (tabId) => {
      console.log('active:', tabId);
    },
    onTabReorder: (tabId, fromIndex, toIndex) => {},
    onTabClosed: (tabId) => {
    },
  });
  return (
    <div>
      <ChromeTabs />
      <button
        onClick={() =>
          addTab({ id: `id-${Date.now()}`, title: `页签`, favicon: false })
        }
      >
        New tab
      </button>
    </div>
  );
}
  1. use component
import { Tabs } from 'react-chrome-tabs';
<Tabs tabs={tabs} onTabActivated={}>