import React, { useState, useContext } from "react"; export type Selection = { type: "address" | "value"; content: string; }; export const useSelection = (): [ Selection | null, React.Dispatch> ] => { const [selection, setSelection] = useState(null); return [selection, setSelection]; }; export const SelectionContext = React.createContext< ReturnType >(null!); export const useSelectionContext = () => { const ctx = useContext(SelectionContext); return ctx; };