@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
19 lines (15 loc) • 586 B
JavaScript
/**
* MSKCC 2021, 2024
*/
import invariant from 'invariant';
const itemToString = item => {
!(typeof item.label === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, '[MultiSelect] the default `itemToString` method expected to receive ' + 'an item with a `label` field of type `string`. Instead received: `%s`', typeof item.label) : invariant(false) : void 0;
return item.label || '';
};
const defaultItemToString = item => {
if (Array.isArray(item)) {
return item.map(itemToString);
}
return itemToString(item);
};
export { defaultItemToString };