I want to understand what the code below does with ternary operator. Right now it is hard to me to decode with ternary operator.
Could someone help me understand what this code does?
const handleSelection = React.useMemo(
() =>
page.map(row => {
return singleSelect
? toggleSingleSelection
? () => toggleSingleSelection(row)
: undefined
: toggleSelection
? () => toggleSelection(row)
: undefined;
}),
[toggleSelection]
);
page.map(row => {
if(singleSelect && toggleSingleSelection) {
return () => toggleSingleSelection(row)
} else if(!singleSelect && toggleSelection) {
return () => toggleSelection(row)
}
})