J. Doe
J. Doe

Reputation: 11

Where is the class "Promise" in this React-Native method example supposed to come from?

This is an example in the React-Native Android docs for using a Native module (a java class) to fulfill a promise:

@ReactMethod
  public void measureLayout(
      int tag,
      int ancestorTag,
      Promise promise) 

https://facebook.github.io/react-native/docs/native-modules-android.html#content

I get the error "cannot find symbol" pointing to Promise and the Android API doesn't seem to have anything to import for it. Where/how am I supposed to get the Promise class?

Upvotes: 1

Views: 1959

Answers (1)

Almouro
Almouro

Reputation: 6524

The Promise class is imported from the com.facebook.react.bridge package.

It was added in react-native 0.15, so make sure android/app/build.gradle compiles a version > 0.15.

For instance, mine is:

...

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.facebook.react:react-native:0.15.+'

    ...
} 

Upvotes: 2

Related Questions