blob: 49deb0c085cb678e3241176c04c9762deb64366b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import React from "react";
import CompletionClient from "../../clients/CompletionClient";
import CompletionType from "../../../shared/CompletionType";
const completionClient = new CompletionClient();
export const useGetCompletionTypes = (): [
CompletionType[] | undefined,
boolean
] => {
type State = {
loading: boolean;
result?: CompletionType[];
};
const [state, setState] = React.useState<State>({ loading: true });
React.useEffect(() => {
completionClient.getCompletionTypes().then((result) => {
setState({ loading: false, result });
});
}, []);
return [state.result, state.loading];
};
|