(options: DefaultOptionType[], fieldNames: FieldNames)
| 160 | // value in Select option should not be null |
| 161 | // note: OptGroup has options too |
| 162 | export function warningNullOptions(options: DefaultOptionType[], fieldNames: FieldNames) { |
| 163 | if (options) { |
| 164 | const recursiveOptions = (optionsList: DefaultOptionType[], inGroup: boolean = false) => { |
| 165 | for (let i = 0; i < optionsList.length; i++) { |
| 166 | const option = optionsList[i]; |
| 167 | |
| 168 | if (option[fieldNames?.value] === null) { |
| 169 | warning(false, '`value` in Select options should not be `null`.'); |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | if ( |
| 174 | !inGroup && |
| 175 | Array.isArray(option[fieldNames?.options]) && |
| 176 | recursiveOptions(option[fieldNames?.options], true) |
| 177 | ) { |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | }; |
| 182 | |
| 183 | recursiveOptions(options); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | export default warningProps; |
no test coverage detected
searching dependent graphs…