-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
🐛 Bug Report
Basically I need to pass and array of objects back to JavaScript every time when I call it from Javascript. My RCT bridge does certain things with array and updates it every time text on my Entry changes. My NSMutableArray is declared in interface so I can access it globally across whole class. Later on I make a call from Javascript to get a new Array, however Array value inside the RCT_EXPORT_METHOD always keeps the first value. It never gets updated.
Expected Behavior
NSMututableArray that I pass back to Javascript should get a new value that has been modified outside the method. Instead it keeps old data. Never updates.
Code Example
RCT_EXPORT_METHOD(findEvents: (NSString *) test
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
NSError *eErr;
if(predictionData != nil){
NSArray *events = predictionData;
if (events) {
resolve(events);
}
else {
eErr = [[NSError alloc] initWithDomain:@"Predictions error"
code:200 userInfo:nil];
reject(@"no_events", @"There were no events", eErr);
}
}
}
- (void) dataReady:(NSArray*) data
{
// self.predictionData = [[NSMutableArray alloc] init];
bool twoWord = false;
[predictionData removeAllObjects];
if(twoWord){
[predictionData addObjectsFromArray:data[0] ];
}
else{
[predictionData addObjectsFromArray:data[1] ];
}
}
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 525.88 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ^16.6.3 => 16.8.2
react-native: ^0.58.4 => 0.58.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7