On the problem of initialValue, the Multiselector of Antd Form and Select

problem description

look at the official documentation and directly set defaultValue= {["a10", "c12"]} to Select < / br > but I can"t get the correct effect after combining form"s initialValue . The contents of the initialValue are displayed, but the contents of the corresponding Option are not displayed. The reason is that the data of the Option option comes from another interface, and initialValue is already in effect before rendering. Is there any way to solve it? You can"t just set the this.props.form.setFiledValue sense.
do you have any ideas to solve the problem? Thank you

the environmental background of the problems and what methods you have tried

initialValue rendered first, but the data of Options has not yet been obtained, which leads to the direct display of username . However, we hope to be able to judge the value after Option rendering, so as to render "${item.realname} ${item.nickname}"

of Option.

clipboard.png

//


:ownersAsListownersList

clipboard.png

Thank you!

Dec.18,2021

you try to change the rendering method of variable assignment. I have been walking in this way

.
 
        const selectList= ownersList.map((item, index) => {
                    <Option key={index} value={item.username}>{`${item.realname}(${item.nickname})`}</Option>
                )}
            
<FormItem {...formItemLayout} label="">
    {getFieldDecorator('ownersAsList', {
        rules: [{
            required: true,
            message: ''
        }],
        initialValue: ownersAsList || []
    })(
        <Select
            mode="multiple"
            placeholder=""  
            onSearch={this.handleSearch}                              
        >
           {selectList}
        </Select>
    )}
</FormItem>

now that form,Option 's value is used, it is not necessary to use

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b399b8-2b925.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b399b8-2b925.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?