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(date-picker): 修复format传入函数,只有在type='weekrange'下生效 #2827

Merged
merged 7 commits into from
May 17, 2024

Conversation

xiamiao1121
Copy link
Contributor

closed #2825

@@ -68,6 +68,10 @@ const Input = ({
vals = vals?.toLocaleUpperCase()
}

if (typeof format === 'function' && date) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

建议将此处理移到第 41 行的上面,直接在该逻辑中更新 value,然后直接 return 不往下执行,这样可以减少不必要的代码执行

@@ -38,6 +38,12 @@ const Input = ({
const [value, setValue] = useState<string | null>('')

useEffect(() => {
if (typeof format === 'function' && date) {
setValue(format(date))
cacheValues.current = format(date)
Copy link
Collaborator

Choose a reason for hiding this comment

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

建议 43 行移到 42 行上面,然后直接 setValue(cacheValues.current)

@zyprepare zyprepare added bug Something isn't working comp:datepicker 4.x labels May 17, 2024
@solarjoker solarjoker merged commit db02632 into XiaoMi:master May 17, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x bug Something isn't working comp:datepicker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatePicker format传入函数,只有在type="weekrange"下生效
3 participants