Skip to content

[PS-22912] fix crash from upgrading to react native 61.5 #5

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

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

lzcheung
Copy link

React Native 61+ changed the type in putMap to accept a ReadableMap instead of a WritableMap. Casting the argument to WritableMap to fix the crash.

android-trophy-crash

Copy link

@nikhil-raina nikhil-raina left a comment

Choose a reason for hiding this comment

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

💯

@@ -471,7 +471,7 @@ public void setContentOffset(float x, float y) {
WritableMap contentOffsetMap = Arguments.createMap();
contentOffsetMap.putDouble("x", PixelUtil.toDIPFromPixel(contentOffset.x));
contentOffsetMap.putDouble("y", PixelUtil.toDIPFromPixel(contentOffset.y));
event.putMap("contentOffset", contentOffsetMap);
event.putMap("contentOffset", (ReadableMap)contentOffsetMap);
Copy link

Choose a reason for hiding this comment

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

Is this a safe cast? Won't throw an error on its own at some point?

Copy link
Author

@lzcheung lzcheung Jun 18, 2020

Choose a reason for hiding this comment

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

Yes, it should be a safe cast since WritableMap extends from ReadableMap so any function it calls from ReadableMap should also be implemented by contentOffsetMap. I'm not sure why it doesn't accept the WritableMap in the first place.

Copy link

@erenn16 erenn16 left a comment

Choose a reason for hiding this comment

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

🔥

@lzcheung lzcheung merged commit 0da27a0 into master Jun 18, 2020
@lzcheung lzcheung deleted the fix-rn-crash branch June 18, 2020 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants