Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react update component after api call

const Settings = () => {
  const [state, setState] = useState({});
  const [isLoading, setIsLoading] = useState(false);

  useEffect(() => {
    const getAllInformation = async () => {
      // start loading
      setIsLoading(true);
      // make the request here
      const data = await fetch();
      setState({ ...data });
      // already finished here
      setIsLoading(false);
    };
    getAllInformation()
  }, []);

  return (
    <div>
      {isLoading ? (
        <Loading />
      ) : (
        {
          /* MORE CODE */
        }
      )}
    </div>
  );
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: store id of an element jquery 
Javascript :: js insert before 
Javascript :: js sort array of objects 
Javascript :: regex for mobile number 
Javascript :: js location 
Javascript :: javascript round date to nearest 15 minutes 
Javascript :: js replace all symbols in string 
Javascript :: unexpected token react native stack navigation 
Javascript :: how do i make a link to direct me to a new page when i click on a button in react 
Javascript :: prototype pollution 
Javascript :: use node js to check if a json file exists 
Javascript :: electron main.js template 
Javascript :: remove empty element from array js 
Javascript :: javascript classlist 
Javascript :: js string length 
Javascript :: open a particular slide on click button in owl carousel 
Javascript :: nextjs localstorage 
Javascript :: vscode js brackets not close 
Javascript :: two decimel javascript 
Javascript :: react-select default menu open 
Javascript :: Convert from JSON to Python 
Javascript :: fetch post 
Javascript :: react toastify dark mode 
Javascript :: javascript form submit on button click check if required fields not empty 
Javascript :: jest match object properties 
Javascript :: javascript flatten an array 
Javascript :: dynamic copyright year js 
Javascript :: insert data from lambda to dynamodb 
Javascript :: javascript enumerate with index 
Javascript :: javascript append to array 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =