-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
🐛 [Bug]: DateTimePicker 设置了popup 属性后参数defaultValue失效了 #608
Labels
Comments
3lang3
added
🕵️♂️ bug
Something isn't working
🙇 help wanted
Extra attention is needed
labels
Jan 5, 2023
Merged
3lang3
added a commit
that referenced
this issue
Jan 12, 2023
* feat: `Stepper` 支持 ref 调用 `focus` `blur`方法 (#590) * chore: stepper types correct * Feat icons build (#593) * fix(Icon): target=es5 for icons build * chore: release icon dev * chore(icons): release 0.0.8 * chore: precommit lint * chore: release 3.0.3 * chore: release v3.0.4 * docs: optimization example (#596) * fix: add button type & optimize condition (#597) * chore: release icons * fix: issues/599 (#600) Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * chore: relase 3.0.5 ver * feat: dropdownMenu自定义选项的选中态勾选icon (#601) * fix: issues/599 * feat: dropdownMenu自定义选项的选中态勾选icon Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * chore: release 3.1.0 * fix: dropdownMenu自定义选项的选中态勾选icon非必填选项 (#602) Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * fix: tabs传入style(#595) (#603) * chore: release 3.1.1 * fix(collapse): fix bug in strict mode(#605) (#606) * fix: close #604 (#610) * fix: close #608 (#609) * chore: release 3.1.2 * fix(Calendar): prevent scroll update in horizontal Co-authored-by: 3lang <675483520@qq.com> Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com> Co-authored-by: 谢俊 <xiejun_ncu@qq.com> Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> Co-authored-by: xiaogonggong-w <79799040+xiaogonggong-w@users.noreply.github.com> Co-authored-by: LZHD <brucefxq@gmail.com>
3lang3
added a commit
that referenced
this issue
Jan 12, 2023
* feat(Calendar): add `horizontal` feature * feat: Fix Calendar/horizontal based on #592 (#612) * feat: `Stepper` 支持 ref 调用 `focus` `blur`方法 (#590) * chore: stepper types correct * Feat icons build (#593) * fix(Icon): target=es5 for icons build * chore: release icon dev * chore(icons): release 0.0.8 * chore: precommit lint * chore: release 3.0.3 * chore: release v3.0.4 * docs: optimization example (#596) * fix: add button type & optimize condition (#597) * chore: release icons * fix: issues/599 (#600) Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * chore: relase 3.0.5 ver * feat: dropdownMenu自定义选项的选中态勾选icon (#601) * fix: issues/599 * feat: dropdownMenu自定义选项的选中态勾选icon Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * chore: release 3.1.0 * fix: dropdownMenu自定义选项的选中态勾选icon非必填选项 (#602) Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> * fix: tabs传入style(#595) (#603) * chore: release 3.1.1 * fix(collapse): fix bug in strict mode(#605) (#606) * fix: close #604 (#610) * fix: close #608 (#609) * chore: release 3.1.2 * fix(Calendar): prevent scroll update in horizontal Co-authored-by: 3lang <675483520@qq.com> Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com> Co-authored-by: 谢俊 <xiejun_ncu@qq.com> Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> Co-authored-by: xiaogonggong-w <79799040+xiaogonggong-w@users.noreply.github.com> Co-authored-by: LZHD <brucefxq@gmail.com> Co-authored-by: TinsFox <fox@tinsfox.com> Co-authored-by: luo3house <96865086+luo3house@users.noreply.github.com> Co-authored-by: 3lang <675483520@qq.com> Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com> Co-authored-by: 谢俊 <xiejun_ncu@qq.com> Co-authored-by: jeff.xie <jeff.xie@usmarthk.com> Co-authored-by: xiaogonggong-w <79799040+xiaogonggong-w@users.noreply.github.com> Co-authored-by: LZHD <brucefxq@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which React Vant packages are impacted?
react-vant
(React Vant core)react-vant-icons
(React Vant Icon)What version of React Vant are you using?
3.1.1
Reproduce live demo(codesandebox or stackblitz)?
No response
Descripition
代码样例
import React, { useState, useEffect, useRef } from "react";
import { DatetimePicker, Field } from "react-vant";
const Demo = () => {
const [value, setValue] = useState(null);
return (
<DatetimePicker
popup={{
round: true,
}}
type="date"
title="选择年月日"
minDate={new Date(2021, 0, 1)}
maxDate={new Date(2025, 10, 1)}
value={value}
defaultValue={new Date()}
onConfirm={setValue}
>
{(val, _, actions) => {
return (
<Field
readOnly
clickable
label="选择年月日"
value={val}
placeholder="请选择日期"
onClick={() => actions.open()}
/>
);
}}
);
};
export default Demo;
注意看图片中,默认选择的日期
设置了popup属性
没有设置popup属性
可能问题出现在DatePicker.js的154行const value = props.popup ? formatValue(props.value) : currentDateRef.current; 传递给formatValue的值没有defaultValue
应该参照
DatePicker.js的33行const [currentDate, setCurrentDate, currentDateRef] = useRefState(() => formatValue(value || defaultValue)) 这样给formatValue传值
The text was updated successfully, but these errors were encountered: