Clarifai / clarifai-javascript

Official Clarifai JavaScript client for browsers and node.js
https://docs.clarifai.com
Other
351 stars 81 forks source link

process.nextTick is not a function #20

Closed yaibait closed 7 years ago

yaibait commented 7 years ago

I try import clarifai to my react native project , when I try

const ClarifaiApp = new Clarifai.App({
  apiKey: 'xxxx'
 });

ClarifaiApp.models.predict(Clarifai.GENERAL_MODEL, "https://samples.clarifai.com/metro-north.jpg").then(
      function(response) {
        // do something with response
        console.log(response);
      },
      function(err) {
        console.log(err);
        // there was an error
      }
    );
  }

I get error process.nextTick is not a function

eddiezane commented 7 years ago

@yaibait it looks like React Native doesn't have a process.nextTick.

We'll look into a better solution for this but for now you can polyfill it with setImmediate

Add this somewhere near the top of your entrypoint:

process.nextTick = setImmediate
yaibait commented 7 years ago

@eddiezane thanks you, it work for me

eddiezane commented 7 years ago

@yaibait glad to hear. Going to keep this open until we find a permanent fix.

eddiezane commented 7 years ago

From the research I've done it seems that polyfilling this is expected by the React Native developer.

Maybe in the future our build tools will avoid this issue entirely.

If anyone finding this issue in the future has any advice otherwise we're all ears!

tetreault commented 5 years ago

thanks @eddiezane - fixed the nextTick error on my end!