-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RCT_EXPORT_METHOD that takes no parameters and returns a promise throws error #17037
Comments
What are you talking about
… On Nov 30, 2017, at 8:48 PM, JPTeasdale ***@***.***> wrote:
Is this a bug report?
Yes
Have you read the Contributing Guidelines <https://facebook.github.io/react-native/docs/contributing.html>?
yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.0
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4408382
Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.3 => 0.49.3
Target Platform: iOS (10.3)
Steps to Reproduce
(Write your steps here:)
Create a native module that returns a promise
TestNativeModule.h
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface TestNativeModule : NSObject <RCTBridgeModule>
@EnD
TestNativeModule.m
@implementation TestNativeModule
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(get: findEventsWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
resolve("test");
}
@EnD
Call it from JS:
const promise = NativeModules.CallToAdventureNative.get();
See the error:
CallToAdventureNative.get was called with 0 arguments but expects 1 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
Note: It works if you pass Anything to the .get function.
Expected Behavior
It would call the function.
Actual Behavior
The error posted above.
Reproducible Demo
It's a native module, can't repro the web
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#17037>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ATjBYY2wbFr95EoBzkAMulkOdI59QFynks5s71rlgaJpZM4QxwA9>.
|
Try:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
FWIW this is still broken as of 0.53, although I believe you can get around it via the hacky solution stated above: In the Objective-C
Then in JS
Like I said, super hacky. |
@anderskev Have you tried:
? |
Something went wrong executing that command, @hramos could you take a look? |
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version? I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer. |
the function
should be:
|
I'm just checking in on this. I'm also running into this error. Is there a better solution than that empty string hack? |
@cmwall The issue here was a incorrect syntax, there's no need for an empty string. What's your native method signature? |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.0
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4408382
Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.3 => 0.49.3
Target Platform: iOS (10.3)
Steps to Reproduce
(Write your steps here:)
TestNativeModule.h
TestNativeModule.m
Note: It works if you pass Anything to the .get function.
Expected Behavior
It would call the function.
Actual Behavior
The error posted above.
Reproducible Demo
It's a native module, can't repro the web
The text was updated successfully, but these errors were encountered: