@@ -27,7 +27,7 @@ import {
|
||||
Typography,
|
||||
} from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import { useAsync } from 'react-hookz';
|
||||
import { useAsync, useMountEffect } from '@react-hookz/web';
|
||||
import { gcpApiRef } from '../../api';
|
||||
|
||||
import {
|
||||
@@ -60,18 +60,12 @@ const DetailsPage = () => {
|
||||
const api = useApi(gcpApiRef);
|
||||
const classes = useStyles();
|
||||
|
||||
const {
|
||||
status,
|
||||
result: details,
|
||||
error,
|
||||
} = useAsync(
|
||||
async () =>
|
||||
api.getProject(
|
||||
decodeURIComponent(location.search.split('projectId=')[1]),
|
||||
),
|
||||
[location.search],
|
||||
const [{ status, result: details, error }, { execute }] = useAsync(async () =>
|
||||
api.getProject(decodeURIComponent(location.search.split('projectId=')[1])),
|
||||
);
|
||||
|
||||
useMountEffect(execute);
|
||||
|
||||
if (status === 'loading') {
|
||||
return <LinearProgress />;
|
||||
} else if (error) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import { Button, LinearProgress, Tooltip, Typography } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
|
||||
import { useAsync } from 'react-hookz';
|
||||
import { useAsync, useMountEffect } from '@react-hookz/web';
|
||||
import { gcpApiRef, Project } from '../../api';
|
||||
|
||||
import {
|
||||
@@ -58,7 +58,10 @@ const labels = (
|
||||
const PageContents = () => {
|
||||
const api = useApi(gcpApiRef);
|
||||
|
||||
const { status, result, error } = useAsync(() => api.listProjects());
|
||||
const [{ status, result, error }, { execute }] = useAsync(() =>
|
||||
api.listProjects(),
|
||||
);
|
||||
useMountEffect(execute);
|
||||
|
||||
if (status === 'loading') {
|
||||
return <LinearProgress />;
|
||||
|
||||
Reference in New Issue
Block a user