Git Product home page Git Product logo

Comments (4)

eps1lon avatar eps1lon commented on July 28, 2024

For context, this throttling could be experienced in React 18 with a larger value (500ms). React 19 used it in more scenarios which lead to the decision to reduce the value.

from react.

phryneas avatar phryneas commented on July 28, 2024

That's very possible, but tbh. we haven't encountered a single situation in our tests where it triggered with React 18 (at least none of our suspense-related test takes over 500ms) - of course that might have been due to the very specific nature of our tests.
Otherwise, you would probably have gotten this request sooner 😉

from react.

eps1lon avatar eps1lon commented on July 28, 2024

There's no need to make it configurable since the throttle heuristic is already skipped when resolved during act.

You can fix this today by manually resolving e.g.

let resolve: (value: string) => void;
const initialPromise = new Promise<string>((_resolve) => {
  resolve = _resolve;
});
...
await act(async () => {
  resolve("test");
});

We'll likely deprecate non-awaited act at some point so that you can just write

-await act(async () => {
+await act(() => {

Though at that point you wouldn't need to manually resolve anyway since await render would've flushed the revealed content. Work for that is being tracked in testing-library/react-testing-library#1214. Note that await render(...) is not sufficient today.

from react.

phryneas avatar phryneas commented on July 28, 2024

This kinda goes opposite to the "you probably don't want to use act at all" advice over in #30031 (comment) 😞

We cannot really have both if this is the only way of avoiding that heuristic. But since the heuristic apparently already is in place, would it be possible to introduce a different way to opt out on top?

from react.

Related Issues (20)

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.