Chapter 6: Implementing Requests and React Suspense

  1. How can we easily create a full REST API from a simple JSON file?
    • We can use the json-server tool to create a full REST API from a JSON file for development and testing
  1. What are the advantages of using a proxy to access our backend server during development?
    • When using a proxy, we do not need to deal with cross-site restrictions during development
  2. Which combinations of Hooks can we use to implement requests?
    • We can implement requests using an Effect and a State or Reducer Hook
  3. Which libraries can we use to implement requests?
    • We can also use the axios and react-request-hook libraries to implement requests
  4. How can we deal with loading states using react-request-hook?
    • We can use the result.isLoading flag returned from the useResource Hook and conditionally display a loading message
  5. How can we deal with errors using react-request-hook?
    • We can use the result.error object returned from the useResource Hook and dispatch an error action
  6. How can we prevent unnecessary re-rendering of components?
    • Using React.memo, we can prevent unnecessary re-rendering, similarly to shouldComponentUpdate
  7. How can we reduce the bundle size of our app?
    • We can use React.Suspense to lazily load certain components, which means that they will only be requested from the server when needed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.30.162