Giter Club home page Giter Club logo

Comments (4)

kentcdodds avatar kentcdodds commented on June 2, 2024

Oh, also, I'm currently getting into an infinite loop in the Suspense stuff.

Here's the block of code that's triggering the infinite loop in the test:

// TODO: the error case leads to an infinite loop in react
// mockFetchPokemon.mockRejectedValue({error: 'fake failure'})
// name.value = 'fail'
// fireEvent.click(getByText(/submit/i))
// expect(mockFetchPokemon).toHaveBeenCalledTimes(1)
// await wait(() => getByText(/error/i))

If you make this return Promise.reject() then you can reproduce the infinite loop in the app:

const pokemonQuery = `

Help there would be super appreciated :)

Here's the code for where that's all happening: https://github.com/kentcdodds/modern-react/blob/master/src/exercises-final/11.js

(Note: I do plan to teach and recommend react-cache (see 12, 13, and 14), I just like to start as simple as possible so people understand what's going on fundamentally).

from modern-react.

kentcdodds avatar kentcdodds commented on June 2, 2024

Oh, and exercise 15 doesn't work yet because you can't currently use Hooks in React.pure. @acdlite mentioned that's an oversight and will be fixed, either way a review of that is appreciated as well :)

from modern-react.

sophiebits avatar sophiebits commented on June 2, 2024

11.js: You probably want to cache the promise so you don't ever do two fetches for the same name. Would the error boundary and placeholder be better in Usage? Generally people err on the side of coupling Placeholders too tightly with individual fetches and we want to discourage that.

12.js/13.js: Best practices on passing down a cache are TBD and might change in the next two weeks.

14.js: Maybe teach React.lazy before other types of suspense? It's easier to wrap your head around I think.

from modern-react.

kentcdodds avatar kentcdodds commented on June 2, 2024

All great tips @sophiebits! Thank you!

from modern-react.

Related Issues (4)

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.