I know my title is quite weird. but allow me explain this first.
const alter = (currentFloor: number) => {
if (overallState.startFloor === '' || overallState.endFloor === '')
return {}
if (
Number(overallState.startFloor) <= currentFloor &&
Number(overallState.endFloor) >= currentFloor
) {
return { selectedKey: overallState.state }
}
return {}
}
/* ... */
return({
randomArray.map((e,index)=>(
<Dropdown
placeholder="placeholder"
options={someoptions}
{...alter(index)} // how does it works????
/>
))
})
I have a function which returns object have prop of fluent UI conditionally.
as you can see, function alter returns object or undefined. but still, it is function.
I never heard about I can spread function itself in curly braces.
These codes work as I intended. but I have no idea how it works.
Can you please ask me what happened in these codes? Thanks.