GithubHelp home page GithubHelp logo

raaynaldo / react-query-blog-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tannerlinsley/react-query-blog-demo

0.0 1.0 0.0 131 KB

An example repo I used to teach a React Query workshop

Home Page: react-summit-2020-react-query.vercel.app

JavaScript 100.00%

react-query-blog-demo's Introduction

What is this?

It's an example repo that show show to go from a simple hook-based application to React Query, avoiding all of the "global state" madness that normally happens!

  • The main branch contains the initial code we started with
  • The with-react-query branch contains the code we ended with after adding react-query
  • The #2 PR currently open in the repo shows the changes between the two

Challenges

  • Convert the custom hooks used to fetch data to use useQuery
  • Implement per-screen background fetching indicators
  • Convert the custom hooks used to create/update/delete to use useMutation
  • Configure mutations to automatically invalidate related queries
  • Implement optimistic updates for mutations
  • Prefetch individual posts on hover using queryCache.prefetchQuery OR
  • Use initialData to show placeholder content for individual posts that pull from the parent posts query
  • Remove per-screen background fetching indicators and instead build a global refetching indicator
  • Dehydrate/hydrate the cache to and from localStorage using the react-query/hydration APIs

How do I develop on this?

  • Run yarn and then yarn dev locally.
  • Open http://localhost:3000 with your browser to see the result.
  • NOTE: The "database" used in this app is simply a JSON file and thus will not work as a deployed application. That said, you are more than welcome to hook it up to a real API if you want!

Why Next.js?

Read This ๐Ÿ˜

react-query-blog-demo's People

Contributors

tannerlinsley avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.