зеркало из https://github.com/microsoft/reactxp.git
Change Image onLoad callback types (#707)
This commit is contained in:
Родитель
5367e91779
Коммит
0b0b4544ad
|
@ -12,7 +12,7 @@
|
|||
"@types/lodash": "^4.14.80",
|
||||
"@types/react": "^16.3.17",
|
||||
"@types/react-dom": "^16.0.6",
|
||||
"@types/react-native": "^0.55.17",
|
||||
"@types/react-native": "^0.55.22",
|
||||
"assert": "^1.3.0",
|
||||
"ifvisible": "^1.1.0",
|
||||
"lodash": "^4.17.4",
|
||||
|
|
|
@ -100,7 +100,7 @@ export class Image extends React.Component<Types.ImageProps, Types.Stateless> im
|
|||
resizeMode={ resizeMode as any }
|
||||
resizeMethod={ this.props.resizeMethod }
|
||||
accessibilityLabel={ this.props.accessibilityLabel }
|
||||
onLoad={ this.props.onLoad ? this._onLoad as any : undefined }
|
||||
onLoad={ this.props.onLoad ? this._onLoad : undefined }
|
||||
onError={ this._onError }
|
||||
{ ...additionalProps }
|
||||
{ ...extendedProps }
|
||||
|
@ -131,17 +131,16 @@ export class Image extends React.Component<Types.ImageProps, Types.Stateless> im
|
|||
return [_styles.defaultImage, this.props.style];
|
||||
}
|
||||
|
||||
private _onLoad = (e: React.SyntheticEvent<Image>) => {
|
||||
private _onLoad = (e: RN.NativeSyntheticEvent<RN.ImageLoadEventData>) => {
|
||||
if (!this._mountedComponent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nativeEvent = e.nativeEvent as any;
|
||||
this._nativeImageWidth = nativeEvent.source.width;
|
||||
this._nativeImageHeight = nativeEvent.source.height;
|
||||
|
||||
this._nativeImageWidth = e.nativeEvent.source.width;
|
||||
this._nativeImageHeight = e.nativeEvent.source.height;
|
||||
|
||||
if (this.props.onLoad) {
|
||||
this.props.onLoad({ width: this._nativeImageWidth!!!, height: this._nativeImageHeight!!! });
|
||||
this.props.onLoad({ width: this._nativeImageWidth!, height: this._nativeImageHeight! });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче