Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 1.15 KB

data-fetching.md

File metadata and controls

19 lines (14 loc) · 1.15 KB

Data fetching

We use the Fetch API (built into browsers) to fetch data. The fetch function is quite simple to use. It returns a Promise that resolves to the response of the request.

We use React Query for state management. State management in React is notoriously hard to get 100% right and safe, which is why using a library such as RQ is a good idea. It saves us from a lot of potential common bugs and headaches with managing state all by ourselves.

If you're not convinced, read this great article by TkDodo on Why You Want Need React Query. It explores a lot of common pitfalls/bugs. At the time of me writing this, these pitfalls/bugs are found absolutely everywhere we do data fetching in Samfundet4. Hopefully over time, we will replace these instances with safe state management using RQ.

Getting started

Please check out the RQ docs Quick Start.