setImmediate is not defined on Meteor + React
See original GitHub issuereact-instantsearch: 2.1.0 Latest versions of Chrome and FF.
Hello, I’ve just started setup react-instantsearch on my Meteor project and have strange bug.
I’m following steps from the React Instant Search Getting Started Tutorial and when I insert first widget (<Hits />
for example) I have an error in console:
modules.js?hash=35e875d…:110624 Uncaught ReferenceError: setImmediate is not defined
at scheduleUpdate (modules.js?hash=35e875d…:110624)
at Object.registerWidget (modules.js?hash=35e875d…:110633)
at new Connector (modules.js?hash=35e875d…:109693)
at modules.js?hash=35e875d…:11541
at measureLifeCyclePerf (modules.js?hash=35e875d…:11321)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (modules.js?hash=35e875d…:11540)
at ReactCompositeComponentWrapper._constructComponent (modules.js?hash=35e875d…:11526)
at ReactCompositeComponentWrapper.mountComponent (modules.js?hash=35e875d…:11434)
at Object.mountComponent (modules.js?hash=35e875d…:4461)
at ReactDOMComponent.mountChildren (modules.js?hash=35e875d…:10623)
It refers to this code:
exports.default = createWidgetsManager; // 6
function createWidgetsManager(onWidgetsUpdate) { // 7
var widgets = []; // 8
// Is an update scheduled? // 9
var scheduled = false; // 10
// 11
// The state manager's updates need to be batched since more than one // 12
// component can register or unregister widgets during the same tick. // 13
function scheduleUpdate() { // 14
if (scheduled) { // 15
return; // 16
} // 17
scheduled = true; // 18
setImmediate(function () { // 19
scheduled = false; // 20
onWidgetsUpdate(); // 21
}); // 22
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Jest Test Error: browserType.launch: setImmediate is not ...
I just added the polyfill.js in my test class : import 'core-js'; after that setImmediate was defined again and works now as intended....
Read more >The definitive Node.js handbook
An incredibly powerful full-stack framework, empowering you with an isomorphic approach to building apps with JavaScript and sharing code on the client and...
Read more >Uncaught ReferenceError: Buffer is not defined angular 13 ...
Queries related to “Uncaught ReferenceError: Buffer is not defined angular 13” · Buffer is not defined · buffer is not defined react ·...
Read more >How to use the asar.createPackage function in asar
setImmediate (() => { this.log.verbose('clearing meteor app after packing'); this. ... if (!name) return res.send({err: new Error('not defined name')}); ...
Read more >8 Essential Node.js Interview Questions and Answers
js in the future. An exception that has bubbled all the way up to the Process level means that your application, and Node.js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm that changing
import algoliasearch from 'algoliasearch'
indom.js
to importalgoliasearch/src/browser/builds/algoliasearch
instead gets this working in Meteor.Hi @Kolyasya,
Currently we are using setImmediate to perform some scheduling and it seems that this function isn’t available with meteor. We are going to change this code to be compatible with the largest lib, but in the meantime one thing you can do is using a
setImmediate
polyfill like this one: https://github.com/YuzuJS/setImmediate. I tried it with a small meteor app and it seems to work fine.Also you are going to have another issue because of the
algoliaClient
we use under the hood ofreact-instantsearch
. To bypass this issue, you can retrieve thealgoliaSearch
client like describe here https://github.com/algolia/algoliasearch-client-javascript/issues/292 and use thealgoliaClient
prop on the<InstantSearch/>
component to instantiate it.Here a working example:
Let me know if this help 😃