-
Why Picker.prompt can't setting value? I used prompt because I didn't want to define the components every time. However, if I use prompt, the value cannot be set, so it is initialized every time. Is there any other way? prompt: (props: Omit<PickerProps, 'value' | 'visible' | 'children'>) => Promise<PickerValue[] | null> <DemoBlock title='指令式调用'>
<Button
onClick={async () => {
const value = await Picker.prompt({
columns: basicColumns,
value: [1] // <----------------------
})
Toast.show(`${value}`)
}}
>
弹出 Picker
</Button>
</DemoBlock> |
Beta Was this translation helpful? Give feedback.
Answered by
GOWxx
May 31, 2022
Replies: 2 comments 4 replies
-
Can you write a simple demo oncodesandbox? It'll help us to check the problem. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I think this works const [pickerState, setPickerState] = useState([]);
onClick={async () => {
await Picker.prompt({
columns: [
[
{ label: "Foo", value: "foo" },
{ label: "Bar", value: "bar" }
]
],
onConfirm: (value) => setPickerState(value),
value: pickerState
});
}} I fork your codesandbox and make changes // line: 5
const [pickerState, setPickerState] = useState([]);
// line: 21
value: pickerState you can check the code here |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
awmleer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this works
I fork your codesandbox and make changes
you can check the code here