rentgen/sidebar/tab-dropdown.tsx
Arkadiusz Wieczorek 01e0901a91 Prettier
2022-01-24 12:21:28 +01:00

31 lines
758 B
TypeScript

import React from 'react';
import { useEffect, useState } from 'react';
export default function TabDropdown({
setPickedTab,
pickedTab,
}: {
setPickedTab: (tab_id: number) => void;
pickedTab: number;
}) {
const [tabs, setTabs] = useState([]);
useEffect(() => {
browser.tabs.query({ currentWindow: true }).then(setTabs);
}, []);
return (
<select
id="tab_dropdown"
value={pickedTab}
onChange={async (e) => {
setPickedTab(parseInt(e.target.value));
}}
>
{tabs.map((tab) => (
<option value={tab.id} key={tab.id}>
{tab.title}
</option>
))}
</select>
);
}