Skip to content

Commit

Permalink
fix: addListener/removeListeners native stubs for react-native 0.65 c…
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Aug 30, 2021
1 parent 4a9c01f commit 168dd8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions android/src/main/java/com/zoontek/rnlocalize/RNLocalizeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ public void onCatalystInstanceDestroy() {
.unregisterReceiver(mBroadcastReceiver);
}

@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}

@ReactMethod
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}

private @NonNull List<Locale> getLocales() {
List<Locale> locales = new ArrayList<>();
Configuration config = getReactApplicationContext()
Expand Down
8 changes: 8 additions & 0 deletions ios/RNLocalize.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,12 @@ - (void)onLocalizationDidChange {
[self sendEventWithName:@"localizationDidChange" body:[self exportedConstants]];
}

RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}

RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
// Keep: Required for RN built in Event Emitter Calls.
}

@end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-localize",
"version": "2.1.1",
"version": "2.1.2",
"license": "MIT",
"description": "A toolbox for your React Native app localization.",
"author": "Mathieu Acthernoene <zoontek@gmail.com>",
Expand Down

3 comments on commit 168dd8a

@cristianoccazinsp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For iOS, it is most likely not required, and will in fact cause issues. Can you revert the iOS change?

@mikehardy

@mikehardy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @zoontek this is an area of active investigation, it appears on iOS adding stubs here disrupts listener behavior in netinfo module at least react-native-netinfo/react-native-netinfo#493 - but no repo (that I know of) actually has an e2e test rigged up where one of these listeners is exercised on iOS so it's all just user reports at the moment. That said, consistent user reports, so I'm going to reverse the stubs on iOS for netinfo at least. I don't personally have time to dig deep on this at the moment unfortunately

@zoontek
Copy link
Owner Author

@zoontek zoontek commented on 168dd8a Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For iOS, it is most likely not required, and will in fact cause issues. Can you revert the iOS change?

@mikehardy

I pushed a rollback

Please sign in to comment.