Skip to content

Commit

Permalink
fix(n-result): show icons on re-render after hydration (#5686)
Browse files Browse the repository at this point in the history
* fix(n-result): show icons on re-render after hydration

* refactor: change iconMap name

---------

Co-authored-by: 07akioni <07akioni2@gmail.com>
  • Loading branch information
becem-gharbi and 07akioni committed Feb 23, 2024
1 parent b6c4be7 commit 53ebcbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
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

0 comments on commit 53ebcbe

Please sign in to comment.