Skip to content

Commit

Permalink
perf(legacy-icon): create the iconNames object only when the module i…
Browse files Browse the repository at this point in the history
…s first evaluated (channel-io#2494)

<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Related Issue

<!-- Please link to issue if one exists -->

- Fixes channel-io#2493

## Summary

<!-- Please brief explanation of the changes made -->

레거시 아이콘을 지원하는 컴포넌트들의 렌더링 성능을 개선합니다.

## Details

<!-- Please elaborate description of the changes -->

- `isIconName` 이 포함된 모듈이 처음 평가되는 시점에 한번만 아이콘 이름 객체를 생성합니다.
- `Set` 을 사용하여 빠르게 탐색할 수 있도록 합니다.

### Breaking change? (Yes/No)

<!-- If Yes, please describe the impact and migration path for users -->

No

## References

<!-- Please list any other resources or points the reviewer should be
aware of -->
  • Loading branch information
sungik-choi authored Nov 8, 2024
1 parent 17521a5 commit ea1a6b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-humans-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@channel.io/bezier-react': patch
---

Improve the rendering performance of components that use `LegacyIcon`.
5 changes: 3 additions & 2 deletions packages/bezier-react/src/components/LegacyIcon/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { type IconName, icons } from '@channel.io/bezier-icons'

const iconNames = new Set(Object.keys(icons))

/**
* @deprecated Please import and use individual icons.
* @example
Expand All @@ -14,5 +16,4 @@ import { type IconName, icons } from '@channel.io/bezier-icons'
* import { LegacyIcon, type LegacyIconProps } from '@channel.io/bezier-react'
* <LegacyIcon name="all" color="bg-black-dark" />
*/
export const isIconName = (name: any): name is IconName =>
Object.keys(icons).includes(name)
export const isIconName = (name: any): name is IconName => iconNames.has(name)

0 comments on commit ea1a6b1

Please sign in to comment.