1
1
import _ from 'lodash' ;
2
- import React , { PropsWithChildren , useEffect , useMemo , forwardRef } from 'react' ;
2
+ import React , { PropsWithChildren , useMemo , forwardRef } from 'react' ;
3
3
import {
4
4
StyleSheet ,
5
5
ImageSourcePropType ,
@@ -11,7 +11,6 @@ import {
11
11
TextStyle ,
12
12
AccessibilityProps
13
13
} from 'react-native' ;
14
- import { LogService } from '../../services' ;
15
14
import { Colors , BorderRadiuses } from '../../style' ;
16
15
import { extractAccessibilityProps } from '../../commons/modifiers' ;
17
16
import Badge , { BadgeProps } from '../badge' ;
@@ -74,10 +73,6 @@ export type AvatarProps = Pick<AccessibilityProps, 'accessibilityLabel'> &
74
73
* The image source (external or assets)
75
74
*/
76
75
source ?: ImageSourcePropType ;
77
- /**
78
- * @deprecated use 'source' prop
79
- */
80
- imageSource ?: ImageSourcePropType ;
81
76
/**
82
77
* Image props object
83
78
*/
@@ -168,7 +163,6 @@ interface Statics {
168
163
const Avatar = forwardRef < any , AvatarProps > ( ( props : AvatarProps , ref : React . ForwardedRef < any > ) => {
169
164
const themeProps = useThemeProps ( props , 'Avatar' ) ;
170
165
const {
171
- imageSource,
172
166
source,
173
167
size = 50 ,
174
168
labelColor = Colors . $textDefault ,
@@ -197,16 +191,6 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw
197
191
const { size : _badgeSize , borderWidth : badgeBorderWidth = 0 } = badgeProps ;
198
192
const badgeSize = _badgeSize || DEFAULT_BADGE_SIZE ;
199
193
200
- useEffect ( ( ) => {
201
- if ( imageSource ) {
202
- LogService . warn ( 'uilib: imageSource prop is deprecated, use source instead.' ) ;
203
- }
204
- } , [ imageSource ] ) ;
205
-
206
- const _source = useMemo ( ( ) => {
207
- return source || imageSource ;
208
- } , [ source , imageSource ] ) ;
209
-
210
194
const _baseContainerStyle : StyleProp < ImageStyle > = useMemo ( ( ) => {
211
195
return {
212
196
width : size ,
@@ -284,13 +268,13 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw
284
268
} , [ size , initialsStyle , labelColor ] ) ;
285
269
286
270
const textContainerStyle = useMemo ( ( ) => {
287
- const hasImage = ! _ . isUndefined ( _source ) ;
271
+ const hasImage = ! _ . isUndefined ( source ) ;
288
272
return [
289
273
styles . initialsContainer ,
290
274
{ backgroundColor : _backgroundColor } ,
291
275
hasImage && styles . initialsContainerWithInset
292
276
] ;
293
- } , [ _source , _backgroundColor ] ) ;
277
+ } , [ source , _backgroundColor ] ) ;
294
278
295
279
const accessibilityProps = useMemo ( ( ) => {
296
280
return extractAccessibilityProps ( props ) ;
@@ -301,13 +285,13 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw
301
285
} , [ _baseContainerStyle , imageStyle ] ) ;
302
286
303
287
const renderImage = ( ) => {
304
- if ( _source !== undefined ) {
288
+ if ( source !== undefined ) {
305
289
// Looks like reanimated does not support SVG
306
- const ImageContainer = animate && ! isSvg ( _source ) ? AnimatedImage : Image ;
290
+ const ImageContainer = animate && ! isSvg ( source ) ? AnimatedImage : Image ;
307
291
return (
308
292
< ImageContainer
309
293
style = { _imageStyle }
310
- source = { _source }
294
+ source = { source }
311
295
onLoadStart = { onImageLoadStart }
312
296
onLoadEnd = { onImageLoadEnd }
313
297
onError = { onImageLoadError }
0 commit comments