mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 12:57:40 -02:30
delete dead code/comments & add useRequest docstring
This commit is contained in:
@@ -37,8 +37,6 @@ function Inventory({ i18n, setBreadcrumb }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try {
|
try {
|
||||||
// TODO: delete next line
|
|
||||||
// setHasContentLoading(true);
|
|
||||||
const { data } = await InventoriesAPI.readDetail(match.params.id);
|
const { data } = await InventoriesAPI.readDetail(match.params.id);
|
||||||
setBreadcrumb(data);
|
setBreadcrumb(data);
|
||||||
setInventory(data);
|
setInventory(data);
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ function InventoryDetail({ inventory, i18n }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchInstanceGroups(inventory.id);
|
fetchInstanceGroups();
|
||||||
}, [fetchInstanceGroups, inventory.id]);
|
}, [fetchInstanceGroups]);
|
||||||
|
|
||||||
const deleteInventory = async () => {
|
const deleteInventory = async () => {
|
||||||
await InventoriesAPI.destroy(inventory.id);
|
await InventoriesAPI.destroy(inventory.id);
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
import { useEffect, useState, useRef, useCallback } from 'react';
|
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) {
|
export default function useRequest(makeRequest, initialValue) {
|
||||||
const [result, setResult] = useState(initialValue);
|
const [result, setResult] = useState(initialValue);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user