2021-07-14 06:52:31 +00:00
|
|
|
import React, { useState, useContext } from "react";
|
|
|
|
|
|
|
|
export type Selection = {
|
2021-07-20 02:33:19 +00:00
|
|
|
type: "address" | "value";
|
2021-07-14 06:52:31 +00:00
|
|
|
content: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useSelection = (): [
|
|
|
|
Selection | null,
|
|
|
|
React.Dispatch<React.SetStateAction<Selection | null>>
|
|
|
|
] => {
|
|
|
|
const [selection, setSelection] = useState<Selection | null>(null);
|
|
|
|
return [selection, setSelection];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SelectionContext = React.createContext<
|
|
|
|
ReturnType<typeof useSelection>
|
|
|
|
>(null!);
|
|
|
|
|
|
|
|
export const useSelectionContext = () => {
|
|
|
|
const ctx = useContext(SelectionContext);
|
|
|
|
return ctx;
|
|
|
|
};
|