undefinedfix
Sign in

React uses the select of antd to report this error?

Buzu edited in Tue, 02 Aug 2022

clipboard.png

index.js:2178 Warning: Failed value type: The value isRequired is marked as required in Select, but its value is undefined.

index.js:2178 Warning: Failed defaultValue type: The defaultValue isRequired is marked as required in Select, but its value is undefined.

public render() {
     for (let i = 0; i < PIC_NUM; i++) {
        options.push(
            <Option key={i.toString()} value={i}>
                <Avatar shape="square" size='small' src={
                    require(`../../../images/puzzle/${i}.jpg`)
                } />
            </Option>
        )
        }
      
   return (
    <Select placeholder='选择图片' style={{ width: 100 }} onChange={this.selectPuzzle}>
            {options}
    </Select>)
}
2 Replies
ePumps
commented on Tue, 02 Aug 2022

The parameter isrequired marked as required is less passed. So either pass the correct parameter isrequired or do not mark required.

fauxkalel
commented on Tue, 02 Aug 2022

This is not an error report, but a warning level one, so there will be no error after packing. This is caused by default value and value not being passed to select. Can you pass it on?

lock This question has been locked and the reply function has been disabled.