-
Notifications
You must be signed in to change notification settings - Fork 141
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
Conversation
fd60537
to
e610f52
Compare
commit: |
e610f52
to
2da43ca
Compare
@@ -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(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMemoのreturnを何も使っておらず、かつ内容の処理が完全に副作用しかないため、useEffectに置き換えました
packages/smarthr-ui/src/components/Dropdown/SortDropdown/useSortDropdown.ts
Outdated
Show resolved
Hide resolved
const onChangeSortOrderRadio = useCallback<ChangeEventHandler<HTMLInputElement>>((e) => { | ||
setCheckedInnerOrder(e.currentTarget.value as Props['defaultOrder']) | ||
}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setCheckedInnerOrder
をそのまま渡すのではなく、実際に利用する形式に変更しました。
eventからvalue属性を参照することで依存関係がない状態にすることで再生成しないようにしています
packages/smarthr-ui/src/components/Dropdown/SortDropdown/SortDropdown.tsx
Show resolved
Hide resolved
packages/smarthr-ui/src/components/Dropdown/SortDropdown/useSortDropdown.ts
Outdated
Show resolved
Hide resolved
…e-refactoring-SortDropdown
4d49707
to
38b2be5
Compare
…e-refactoring-SortDropdown
38b2be5
to
1ce0caf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
関連URL
概要
変更内容
確認方法