MCPcopy Create free account
hub / github.com/react-component/select / warningNullOptions

Function warningNullOptions

src/utils/warningPropsUtil.ts:162–185  ·  view source on GitHub ↗
(options: DefaultOptionType[], fieldNames: FieldNames)

Source from the content-addressed store, hash-verified

160// value in Select option should not be null
161// note: OptGroup has options too
162export 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
187export default warningProps;

Callers 1

Select.tsxFile · 0.90

Calls 1

recursiveOptionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…