arco-design/arco-design-mobile

Dialog里面的Radio是无法变更value的,好奇怪,详情里面有codeopen案例

Closed this issue · 4 comments

Basic Info

  • Package Name And Version: @arco-design/mobile-react@2.29.1

Steps to reproduce

详情请看这个代码案例,我无法变更选项内容了
https://codepen.io/2513483494/pen/NWePLoR?editors=1111

const { React, Arco, ArcoIcon } = window;
const { Dialog, Cell, Button, Radio } = Arco;

function DialogDemo() {
const [visible, setVisible] = React.useState(false);
const [v, setv] = React.useState(1);
return (


<Button onClick={() => {
Dialog.confirm({
platform: 'ios',
title: '风险忽略原因',
children: (
<>
<Radio.Group
value={v}
onChange={setv}
>
已有拜访
已与客户沟通
其他
</Radio.Group>
</>
),
});
}}>111
);
}
ReactDOM.render(, mountNode);

hello change your code

onChange={value => {
    setv(value);
}}

try again

@2513483494 同学,通过方法(Dialog.confirm)调用的组件,不属于你当前组件的子组件,自然也不会参与当前组件的生命周期,即在当前组件的value这个state变化的时候,不会触发Dialog的children的重绘。这里2个选择:1. Radio去掉value属性,不使用受控模式;2. Dialog使用组件形式调用而非方法调用

晓得了