Skip to content

Commit 96e7f71

Browse files
committed
update Avatar
1 parent 740485d commit 96e7f71

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

packages/mui-joy/src/Avatar/Avatar.tsx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,6 @@ const Avatar = React.forwardRef(function Avatar(inProps, ref) {
169169
grouped: !!groupContext,
170170
};
171171

172-
// Use a hook instead of onError on the img element to support server-side rendering.
173-
const loaded = useLoaded({
174-
...imgProps,
175-
...(typeof other.slotProps?.img === 'function'
176-
? other.slotProps?.img(ownerState)
177-
: other.slotProps?.img),
178-
src,
179-
srcSet,
180-
});
181-
182-
const hasImg = src || srcSet;
183-
const hasImgNotFailing = hasImg && loaded !== 'error';
184-
185172
const classes = useUtilityClasses(ownerState);
186173

187174
const [SlotRoot, rootProps] = useSlot('root', {
@@ -212,6 +199,17 @@ const Avatar = React.forwardRef(function Avatar(inProps, ref) {
212199
ownerState,
213200
});
214201

202+
// Use a hook instead of onError on the img element to support server-side rendering.
203+
const loaded = useLoaded({
204+
...imgProps,
205+
...imageProps,
206+
src,
207+
srcSet,
208+
});
209+
210+
const hasImg = src || srcSet;
211+
const hasImgNotFailing = hasImg && loaded !== 'error';
212+
215213
if (hasImgNotFailing) {
216214
children = <SlotImg {...imageProps} />;
217215
} else if (childrenProp != null) {
@@ -262,14 +260,6 @@ Avatar.propTypes /* remove-proptypes */ = {
262260
PropTypes.oneOf(['lg', 'md', 'sm']),
263261
PropTypes.string,
264262
]),
265-
/**
266-
* @ignore
267-
*/
268-
slotProps: PropTypes.shape({
269-
fallback: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
270-
img: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
271-
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
272-
}),
273263
/**
274264
* The `src` attribute for the `img` element.
275265
*/

0 commit comments

Comments
 (0)