mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -04:00
* tabs w/ multiple router instances * fix router switching * keybinds * manual history tracking * eslint * remove scroll restoration * fix tab removal * route title + tab create delay * typescript * put tab list up top * Remove import + show close button only if tabs length more than 1 * lint * unify blur across whole top bar * add to keybindings page, tauri drag region, and tooltip * fix blur * more drag regions * merge moment --------- Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com>
18 lines
438 B
TypeScript
18 lines
438 B
TypeScript
import { createContext, useContext, useLayoutEffect } from 'react';
|
|
|
|
export function useRouteTitle(title: string) {
|
|
const ctx = useContext(RouteTitleContext);
|
|
|
|
// layout effect avoids 'New Tab' showing up briefly
|
|
useLayoutEffect(() => {
|
|
document.title = title;
|
|
if (ctx) ctx.setTitle(title);
|
|
}, [title, ctx]);
|
|
|
|
return title;
|
|
}
|
|
|
|
export const RouteTitleContext = createContext<{
|
|
setTitle: (title: string) => void;
|
|
} | null>(null);
|