mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-30 07:51:17 -07:00
12 lines
389 B
React
12 lines
389 B
React
import { createContext, useMemo, useState } from "react";
|
|
|
|
export const TabContext = createContext();
|
|
|
|
export function TabProvider({ initialTab, children }) {
|
|
const [activeTab, setActiveTab] = useState(() => initialTab ?? false);
|
|
|
|
const value = useMemo(() => ({ activeTab, setActiveTab }), [activeTab]);
|
|
|
|
return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
|
|
}
|