SHARE
TWEET

Untitled

a guest Mar 20th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { useState, useEffect } from 'react';
  2. import OrderService from './OrderService';
  3.  
  4. function useOrders() {
  5.   const [orders, setOrders] = useState([]);
  6.  
  7.   async function fetchOrders() {
  8.     const orders = await OrderService.get();
  9.     setOrders(orders);
  10.   }
  11.  
  12.   useEffect(() => {
  13.     fetchOrders();
  14.   }, []);
  15.  
  16.   return { orders };
  17. }
  18.  
  19. export default useOrders;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top