Unverified Commit d23b1601 authored by lijianan's avatar lijianan Committed by GitHub

style: remove useless React.Fragment tag on `next/image` (#48997)



### What?

remove useless React.Fragment tag

### Why?

<img /> is a single element, No need `<></>` as an outer wrapper

### How?
parent 25ba8a74
...@@ -418,7 +418,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>( ...@@ -418,7 +418,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>(
) => { ) => {
loading = isLazy ? 'lazy' : loading loading = isLazy ? 'lazy' : loading
return ( return (
<>
<img <img
{...rest} {...rest}
{...getDynamicProps(fetchPriority)} {...getDynamicProps(fetchPriority)}
...@@ -454,10 +453,7 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>( ...@@ -454,10 +453,7 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>(
} }
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
if (!srcString) { if (!srcString) {
console.error( console.error(`Image is missing required "src" property:`, img)
`Image is missing required "src" property:`,
img
)
} }
if (img.getAttribute('alt') === null) { if (img.getAttribute('alt') === null) {
console.error( console.error(
...@@ -512,7 +508,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>( ...@@ -512,7 +508,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>(
} }
}} }}
/> />
</>
) )
} }
) )
...@@ -546,7 +541,7 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>( ...@@ -546,7 +541,7 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>(
forwardedRef forwardedRef
) => { ) => {
const configContext = useContext(ImageConfigContext) const configContext = useContext(ImageConfigContext)
const config: ImageConfig = useMemo(() => { const config = useMemo<ImageConfig>(() => {
const c = configEnv || configContext || imageConfigDefault const c = configEnv || configContext || imageConfigDefault
const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b) const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b)
const deviceSizes = c.deviceSizes.sort((a, b) => a - b) const deviceSizes = c.deviceSizes.sort((a, b) => a - b)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment