mirror of
https://github.com/ansible/awx.git
synced 2026-01-19 13:41:28 -03:30
delete dead code/comments & add useRequest docstring
This commit is contained in:
parent
370a7f9b25
commit
638e8c7add
@ -37,8 +37,6 @@ function Inventory({ i18n, setBreadcrumb }) {
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
try {
|
||||
// TODO: delete next line
|
||||
// setHasContentLoading(true);
|
||||
const { data } = await InventoriesAPI.readDetail(match.params.id);
|
||||
setBreadcrumb(data);
|
||||
setInventory(data);
|
||||
|
||||
@ -31,8 +31,8 @@ function InventoryDetail({ inventory, i18n }) {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
fetchInstanceGroups(inventory.id);
|
||||
}, [fetchInstanceGroups, inventory.id]);
|
||||
fetchInstanceGroups();
|
||||
}, [fetchInstanceGroups]);
|
||||
|
||||
const deleteInventory = async () => {
|
||||
await InventoriesAPI.destroy(inventory.id);
|
||||
|
||||
@ -1,5 +1,16 @@
|
||||
import { useEffect, useState, useRef, useCallback } from 'react';
|
||||
|
||||
/*
|
||||
* The useRequest hook accepts a request function and returns an object with
|
||||
* four values:
|
||||
* request: a function to call to invoke the request
|
||||
* result: the value returned from the request function (once invoked)
|
||||
* isLoading: boolean state indicating whether the request is in active/in flight
|
||||
* error: any caught error resulting from the request
|
||||
*
|
||||
* The hook also accepts an optional second parameter which is a default
|
||||
* value to set as result before the first time the request is made.
|
||||
*/
|
||||
export default function useRequest(makeRequest, initialValue) {
|
||||
const [result, setResult] = useState(initialValue);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user