I have looked up this issue and so far is seems that most of these error are caused by typos, but I'm pretty sure I don't have one. With this code:
const Component = (props: Props): ReactElement => {
const createColumnData = (): ColumnProps<TableDataPoint>[] => Object.keys(
props.dataSource[0],
)
.map((key, _, arr) => ({
title: key.replace(/([A-Z])/g, ' $1').replace(/^./, (str) => str.toUpperCase()),
dataIndex: key,
width: `${100 / Math.floor(arr.length)}%`,
render: props.columnLinks[key]
? ((text): ReactElement => <a href={props.columnLinks[key]}>{text}</a>) // error is in columnLinks here
: undefined,
}));
I get the error 'columnLinks' is missing in props validation
and I'm not sure why. Has it got to do with passing JS in to an href?
Also I am aware that there is no point in using a ternary operator with one branch returning undefined, but TypeScript is throwing an error when I use &&
in this situation.