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

chore: SortDropdownの内部処理をリファクタリングする #5311

Merged
merged 12 commits into from
Feb 6, 2025

Conversation

AtsushiM
Copy link
Member

関連URL

概要

変更内容

確認方法

@yagimushi yagimushi force-pushed the chore-refactoring-SortDropdown branch from fd60537 to e610f52 Compare January 21, 2025 22:15
Copy link

pkg-pr-new bot commented Jan 21, 2025

Open in Stackblitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5311

commit: e0ba421

@yagimushi yagimushi force-pushed the chore-refactoring-SortDropdown branch from e610f52 to 2da43ca Compare January 21, 2025 22:18
@@ -50,21 +54,23 @@ export const useSortDropdown = ({ sortFields, defaultOrder, onApply, decorators
const [innerSelectedField, setInnerSelectedField] = useState<string>()
const [innerCheckedOrder, setCheckedInnerOrder] = useState<Props['defaultOrder']>(defaultOrder)

useMemo(() => {
useEffect(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useMemoのreturnを何も使っておらず、かつ内容の処理が完全に副作用しかないため、useEffectに置き換えました

Comment on lines +113 to +115
const onChangeSortOrderRadio = useCallback<ChangeEventHandler<HTMLInputElement>>((e) => {
setCheckedInnerOrder(e.currentTarget.value as Props['defaultOrder'])
}, [])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setCheckedInnerOrder をそのまま渡すのではなく、実際に利用する形式に変更しました。
eventからvalue属性を参照することで依存関係がない状態にすることで再生成しないようにしています

@AtsushiM AtsushiM marked this pull request as ready for review January 21, 2025 22:23
@AtsushiM AtsushiM requested a review from a team as a code owner January 21, 2025 22:23
@AtsushiM AtsushiM requested review from moshisora and hiroki0525 and removed request for a team January 21, 2025 22:23
@AtsushiM AtsushiM requested a review from Qs-F February 2, 2025 22:04
@yagimushi yagimushi force-pushed the chore-refactoring-SortDropdown branch from 4d49707 to 38b2be5 Compare February 5, 2025 23:48
@yagimushi yagimushi force-pushed the chore-refactoring-SortDropdown branch from 38b2be5 to 1ce0caf Compare February 5, 2025 23:49
Copy link
Contributor

@Qs-F Qs-F left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AtsushiM AtsushiM merged commit 21f116e into master Feb 6, 2025
15 checks passed
@AtsushiM AtsushiM deleted the chore-refactoring-SortDropdown branch February 6, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants