Giter VIP home page Giter VIP logo

usequery's Introduction

Description

This is a simple Create React App demonstrating a bug with Apollo's "useQuery" with the new version of React 16.3.0.

Duplicating

npm install
npm run start

Then, open the developer tools window and you'll sometimes see the warning:

index.js:1 Warning: Cannot update a component from inside the function body of a different component.
    in InnerComponent (at src/index.tsx:41)
    in WrapperComponent (at src/index.tsx:52)
    in ApolloProvider (at src/index.tsx:46)

Increasing the number of WrapperComponent will also increase the chance of the warning:

  • 1 component will NEVER throw a warning
  • 2 component will SOMETIMES throw a warning
  • 3 component will ALWAYS throw 1 to 3 warnings

There are a number of ways to make this error disappear:

  1. Remove the if (loading) check on line 37 in src/index.tsx.
  2. The unique values of the WrapperComponent are set to the same value
  3. Change requestDetails node to return the same value (server side)
  4. Setting fetchPolicy: 'network-only' in the InnerComponent's query

From this I would infer that updates caused by cache changes are the cause of the warning.

usequery's People

Contributors

bogdibota 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.