Advertisement
fabiobiondi

React Pro - Real World App - Ch8. 01 - 01. da useState a useReducer - Parte 1

Mar 19th, 2023 (edited)
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import { useReducer } from 'react';
  3.  
  4. function productsReducer(state: any, action: any) {
  5.   return state;
  6. }
  7.  
  8.  
  9. export function CMSProductsPage() {
  10.   const [state, dispatch] = useReducer(productsReducer, { pending: false });
  11.  
  12.   console.log(state)
  13.  
  14.   return (
  15.     <div>
  16.       <h1 className="title">CMS</h1>
  17.  
  18.       <hr className="my-8"/>
  19.  
  20.       { state.pending && <div>Loading</div>}
  21.  
  22.       <pre>{JSON.stringify(state, null, 2)}</pre>
  23.  
  24.     </div>
  25.   )
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement