-
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 always keeps the same value for NSMutuableArray #23513
Comments
Please bear in mind that placing breakpoint inside "dataReady" method shows that value does get updated. Somehow predictionData stays the same inside the RCT_EXPORT_METHOD. I also tried using RCT_REMAP_METHOD, with the same outcome. |
It looks like you are using an older version of React Native. Please update to the latest release, v0.58 and verify if the issue still exists. The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running |
Also, since you forced me to update to newest react-native it broke my remote debugger for iOS (Android remote debugger is already broke), so i cannot debug my javascript anymore. Debugger issue: #23235 Thx in advance. |
I am sorry you ran into that other issue. No one's forcing anyone to upgrade. We're interested in tracking issues that are known to be present in the latest released version, to keep maintainers from spending time chasing issues that might already be fixed. |
@WojTherapy The issue you mentioned has been fixed in the
Regarding the original issue, could you please create a repo with the relevant native code that shows the error so we can take a look? Nonetheless, I don't think your issue has anything to do with React Native in itself because it doesn't do any special handling for functions and variables inside it. It could be a bug in the Objective C code that you have. |
I dont think it is Objective C bug as changing the value of my variable in any other method, at any other point behaves as expected. The only place where it retains just the first value is within the RCT_REMAP_METHOD or RCT_EXPORT_METHOD. Passing props back to JavaScript behaves as expected as I receive them in JS, its just that the value is wrong(due to retaining original value). When you put breakpoint inside those react methods, the value is always the same, always, unless I modify it within the RCT_REMAP_METHOD/RCT_EXPORT_METHOD. It seems like Macro never gets updated unless value is modified within those methods. I will create a repo on the weekend when I get a minute. It is worth noting that I solved the issue by making the variable static "static NSArray *predictionData;", but Id rather not to use static fields. Thx for answer, and sorry for bit of attitude. I have been very frustrated with React Native recently. |
@WojTherapy I'm happy to help you figure out what's happening once you provide a repro. For now what you can do is, compare the |
If we can get a repo for this we're happy to re-open and take a look 👍 |
🐛 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
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
The text was updated successfully, but these errors were encountered: