RN: Consistent API for Image Events

Summary:
Changes the `onLoad` and `onError` events on `Image` to be consistent with each other and with the `ImageSource` type.

Changelog:
[Android][Breaking] - On `Image`, `onLoad` and `onError` event objects will no longer have an extra `uri` property.
[Android][Breaking] - On `Image`, `onLoad` event objects' `source.url` is now renamed to `source.uri`.
[iOS][Breaking] - On `Image`, `onLoad` event objects' `source.url` is now renamed to `source.uri`.

Reviewed By: mdvacca

Differential Revision: D22023565

fbshipit-source-id: 5ea7904c697f87e01118bdb81ed50ab0a5aecdce
This commit is contained in:
Tim Yung
2020-06-16 15:01:05 -07:00
committed by Facebook GitHub Bot
parent 90997c26e3
commit 74ab8f6e5a
4 changed files with 5 additions and 10 deletions
@@ -107,14 +107,10 @@ public class ImageLoadEvent extends Event<ImageLoadEvent> {
switch (mEventType) {
case ON_LOAD:
eventData = Arguments.createMap();
// TODO: Remove this (to be less redundant and to be consistent with iOS).
eventData.putString("uri", mSourceUri);
eventData.putMap("source", createEventDataSource());
break;
case ON_ERROR:
eventData = Arguments.createMap();
// TODO: Remove this (to be less redundant and to be consistent with iOS).
eventData.putString("uri", mSourceUri);
eventData.putString("error", mErrorMessage);
break;
}
@@ -124,9 +120,9 @@ public class ImageLoadEvent extends Event<ImageLoadEvent> {
private WritableMap createEventDataSource() {
WritableMap source = Arguments.createMap();
source.putString("uri", mSourceUri);
source.putDouble("width", mWidth);
source.putDouble("height", mHeight);
source.putString("url", mSourceUri);
return source;
}
}