import { Outlet, useParams } from "react-router-dom"; import { Family, FamilyApi } from "../api/FamilyApi"; import React from "react"; import { AsyncWidget } from "./AsyncWidget"; interface FamilyContext { family: Family; reloadFamilyInfo: () => void; } const FamilyContextK = React.createContext(null); export function BaseFamilyRoute(): React.ReactElement { const { familyId } = useParams(); const [family, setFamily] = React.useState(null); const loadKey = React.useRef(1); const load = async () => { setFamily(await FamilyApi.GetSingle(Number(familyId))); }; const onReload = () => { loadKey.current += 1; setFamily(null); }; return ( (

base family route

)} /> ); } export function useFamily(): FamilyContext { return React.useContext(FamilyContextK)!; }