Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VCCI-News
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Văn Hoàng
VCCI-News
Commits
f08bcb7f
Commit
f08bcb7f
authored
Dec 04, 2025
by
Phạm Quang Bảo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update/components image Next support ssr
parent
daccd38d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
index.tsx
src/components/shared/image-next/index.tsx
+27
-5
No files found.
src/components/shared/image-next/index.tsx
View file @
f08bcb7f
"use client"
;
import
Image
from
"next/image"
;
import
{
useState
}
from
"react"
;
const
ImageNext
=
({
src
,
alt
,
width
,
height
,
className
,
onError
}:
any
)
=>
{
const
ImageNext
=
({
src
,
alt
,
width
,
height
,
className
,
onErrorFallback
}:
{
src
:
string
;
alt
?:
string
;
width
:
number
;
height
:
number
;
className
?:
string
;
onErrorFallback
?:
string
})
=>
{
const
fallbackSrc
=
onErrorFallback
||
"/img-error.png"
;
const
[
imgSrc
,
setImgSrc
]
=
useState
(
src
);
return
(
<
Image
src=
{
imgSrc
}
alt=
{
alt
}
src=
{
imgSrc
||
fallbackSrc
}
alt=
{
alt
||
""
}
width=
{
width
}
height=
{
height
}
className=
{
className
}
onError=
{
()
=>
setImgSrc
(
onError
||
"/img-error.png"
)
}
unoptimized
onError=
{
()
=>
{
if
(
imgSrc
!==
fallbackSrc
)
{
setImgSrc
(
fallbackSrc
);
}
}
}
/>
);
};
export
default
ImageNext
;
export
default
ImageNext
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment