Skip to content

[Bug] 当在Form.Item里面使用DatePicker的时候,值无法改变 #1415

@snowwindsand

Description

@snowwindsand

💬 Before You Start

  • I have searched the issues of this repository and believe that this is not a duplicate.

🙋 Description/Step to reproduce

参考Form.Item的示例,创建一个DatePicker,值无法改变

<Form.Item
            label="创建日期"
            name="createdate"
            rules={[{ required: true, message: '创建日期不能为空' }]}
            arrow="horizontal"
            onPress={() => {
              pickerRef.current.toggle()
            }}>
            <DatePicker  ref={pickerRef}>
              {({ extra, value, toggle }) => (
                <Input
                  value={value?.length ? extra : undefined}
                  onFocus={toggle}
                  placeholder=""
                />
              )}
            </Picker>
          </Form.Item>

如果在DatePicker上面加上onChange事件,是可以看到value改变了,但是下面的Input不会改变。
可以看到extra和value永远是当天日期 比如 extra: 2025-03-05, value: ['2025', '03', '05']

🔴 Version

8.19.4

💻 Environment

Android

⚫️ Output of npx react-native info

System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 29.61 GB / 63.38 GB
Binaries:
Node:
version: 16.20.2
path: D:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: F:\Projects\xxxxx\node_modules.bin\yarn.CMD
npm:
version: 8.19.4
path: D:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "33"
- "34"
Build Tools:
- 23.0.1
- 23.0.3
- 24.0.3
- 25.0.3
- 26.0.2
- 26.0.3
- 27.0.0
- 27.0.3
- 28.0.3
- 29.0.2
- 30.0.2
- 30.0.3
- 31.0.0
- 33.0.0
- 34.0.0
System Images:
- android-31 | Google APIs Intel x86_64 Atom
Android NDK: Not Found
Windows SDK:
AllowAllTrustedApps: Enabled
AllowDevelopmentWithoutDevLicense: Enabled
IDEs:
Android Studio: Not Found
Visual Studio:
- 17.11.35327.3 (Visual Studio Community 2022)
Languages:
Java:
version: 17.0.11
path: D:\Program Files\Microsoft\jdk-17.0.11.9-hotspot\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.5
wanted: 0.72.5
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions