From cd393b0b4912cb592ba4ea4dd36d9b6139037c39 Mon Sep 17 00:00:00 2001 From: vagusX Date: Sat, 5 Mar 2022 13:58:08 +0800 Subject: [PATCH] feat: use value as default label --- src/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 09c0a2d..5d9b6a0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -36,7 +36,12 @@ export interface SegmentedProps extends React.HTMLProps { function normalizeOptions(options: SegmentedOptions): SegmentedLabeledOption[] { return options.map((option) => { if (typeof option === 'object') { - return option || {}; + return { + ...option, + // use value as default label + label: + typeof option.label !== 'undefined' ? option.label : option.value, + }; } return { label: option?.toString(),