What should be the standard return argument of the onChange method for Selector, Checkbox... which have the list of options object{value, label} as the input?
you guys prefer an object{value, label} or a single value? It looks like this:
onChange: (event, option: object{label, value}) => {};
or
onChange: (event, value) => {};
Update: Sorry, my question is not clear and I'll add more context to it.
My project has a components library and I'm creating some components like Selector, Checkbox... which have the list of options object{value, label} as the input:
type optionProps = {
value: string;
label?: string;
};
export interface SelectorProps {
options: Array<optionsProps>;
values?: string[];
onChange?: (event: Event, options: optionsProps) => void;
}
Notice the onChange function, some ppl told me the onChange function only needs to return the value (not a whole option) as the 2nd argument.
And I'm not sure what is more appropriate. Thanks.