Giter Site home page Giter Site logo

Comments (6)

TheSharpieOne avatar TheSharpieOne commented on June 9, 2024

Eh, I figured that thing would be a thing by now (and I thought it was seeing how nodejs has it which I thought meant chrome did as well), but it looks like Chrome and Firefox don't like it for various "reasons" (very longs issue threads...). It is a standard, just an unofficial one which looks like will it never make it pass the editor's draft phase.
We use drafts all of the time (though usually working drafts) and depend on polyfills and transforms to allow us to use them.
Also, if you are using react, you are already including a polyfill for setImmediate via: setimmediate <- fbjs <- react

That being said, I'm going to make it so setImmediate doesn't need to be defined. ((window.setImmediate || setTimeout)(() => this.topFocus && this.topFocus.focus()); will probably work best)

from react-block-ui.

benpptung avatar benpptung commented on June 9, 2024

I am using react, but I don't use the polyfill, I guess this is why I got that error. :)
Thank you for your reply, I've solved it already.

from react-block-ui.

TheSharpieOne avatar TheSharpieOne commented on June 9, 2024

I am not 100% sure how you are not using the polyfill since it is included with react via react's dependencies. Maybe treeshaking is removing it?

from react-block-ui.

benpptung avatar benpptung commented on June 9, 2024

I've been looking into React's code, and React doc website https://facebook.github.io/react/docs/hello-world.html, and I think React doesn't include setImmediate, because

  1. If we open the browser's console, type typeof setImmediate on the React website, it is undefined. It means no setImmediate exist in global, even React exist.

  2. And it seems React doesn't require setImmediate from fbjs to attach it to global.

So, you can find setImmediate in the global scope? ...mmm ... weird :)

from react-block-ui.

TheSharpieOne avatar TheSharpieOne commented on June 9, 2024

I have never used react with UMD imports and script tags like that, it appears they have a special build which limits the things they import from fbjs probably to help minimize the size. https://github.com/facebook/react/blob/2fa38ac1cce658ce799a162e65fcf782187c8802/scripts/rollup/modules.js#L188-L196

from react-block-ui.

benpptung avatar benpptung commented on June 9, 2024

Yes ... :) I am still using require, and using browserify to bundle react.

so, if we cannot guarantee setImmediate() exist in global scope, I suggest to use setTimeout({fn}, 0), which should always works across browsers and server-rendering.

from react-block-ui.

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.