Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
func: (prop: SomeTerm) => React.ReactNode,
associationRenderer: React.ReactType,
): React.ReactElement | null {
const associationProps = associationRenderer !== React.Fragment ? props : null;
if (objRaw.length === 0) {
return null;
} else if (objRaw.length === 1) {
return React.createElement(associationRenderer, associationProps, func(objRaw[0]));
} else if (props.limit === 1) {
return React.createElement(
associationRenderer,
associationProps,
// @ts-ignore
func(getTermBestLang(objRaw, lrs.store.langPrefs)),
);
}
const pLimit = Math.min(...[props.limit, objRaw.length].filter(Number) as number[]);
const elems = new Array(pLimit);
for (let i = 0; i < pLimit; i++) {
elems.push(func(objRaw[i]));
}
return React.createElement(associationRenderer, associationProps, elems);
}