Skip to content

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.

💯

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.

4 participants