Skip to content

Commit 0c16811

Browse files
yusufffethanshar
andauthored
Invoke onLoad prop on onLoad (#1033)
* Invoke onLoad prop on onLoad * Add missing onLoad args * Spread args on onLoad parameters Co-authored-by: Ethan Sharabi <[email protected]> Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 0c0d4f2 commit 0c16811

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/animatedImage/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// TODO: consider unify this component functionality with our Image component
2+
import _ from 'lodash';
23
import PropTypes from 'prop-types';
34
import React from 'react';
45
import {Animated, View, StyleSheet} from 'react-native';
@@ -43,11 +44,12 @@ class AnimatedImage extends BaseComponent {
4344
this.state = {opacity: new Animated.Value(0), isLoading: true};
4445
}
4546

46-
onLoad = () => {
47+
onLoad = (...args) => {
4748
this.setState({isLoading: false}, () => {
4849
const animationParams = {toValue: 1, duration: this.props.animationDuration, useNativeDriver: true};
4950
Animated.timing(this.state.opacity, animationParams).start();
5051
});
52+
_.invoke(this.props, 'onLoad', ...args);
5153
};
5254

5355
render() {
@@ -58,7 +60,7 @@ class AnimatedImage extends BaseComponent {
5860
{...others}
5961
style={[{opacity: this.state.opacity}, style]}
6062
source={source}
61-
onLoad={() => this.onLoad()}
63+
onLoad={this.onLoad}
6264
testID={testID}
6365
/>
6466
{this.state.isLoading && loader && (

0 commit comments

Comments
 (0)