Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(n-result): show icons on re-render after hydration #5686

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Fix `n-split`'s `min` attribute does not take effect
- Fix `n-result` built-in icons not re-rendered after hydration.

### Features

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- 修复 `n-split` 的 `min` 属性未生效
- Fix `n-result` built-in icons not re-rendered after hydration.

### Features

Expand Down
20 changes: 10 additions & 10 deletions src/result/src/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import image418 from './418'
import image403 from './403'
import style from './styles/index.cssr'

const iconMap = {
403: image403,
404: image404,
418: image418,
500: image500,
info: <InfoIcon />,
success: <SuccessIcon />,
warning: <WarningIcon />,
error: <ErrorIcon />
const iconRenderMap = {
403: () => image403,
404: () => image404,
418: () => image418,
500: () => image500,
info: () => <InfoIcon />,
success: () => <SuccessIcon />,
warning: () => <WarningIcon />,
error: () => <ErrorIcon />
}

export const resultProps = {
Expand Down Expand Up @@ -130,7 +130,7 @@ export default defineComponent({
<div class={`${mergedClsPrefix}-result-icon`}>
{$slots.icon?.() || (
<NBaseIcon clsPrefix={mergedClsPrefix}>
{{ default: () => iconMap[status] }}
{{ default: () => iconRenderMap[status]() }}
</NBaseIcon>
)}
</div>
Expand Down