phtabs
v1.0.0
Published
PHT
Downloads
3
Readme
React Chrome Tabs
Usage
- 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>
);
}
- use component
import { Tabs } from 'react-chrome-tabs';
<Tabs tabs={tabs} onTabActivated={}>