I'm currently utilizing ramda's toPairs
method.
import { toPairs } from 'ramda';
renderMenuItems({ copy, remove, add, update }) {
return (
toPairs({ copy, remove, add, update })
// verify if the value is a function.
.filter(([, val]) => typeof val === 'function')
.map(([key, value], idx) =>
<MenuItem
key={idx}
icon={ICONS[key]} //Error: Type '{}' cannot be used as an index type
caption={CAPTIONS[key]}
onClick={() => value()}
/>,
)
);
}
The types of key
and value
are both {}
. However, according to the documentation (), it should be a string.
Can anyone provide assistance in resolving this issue?