I recently upgraded typescript and I am getting the above error in one of my components.
I have the following code in that component render method:
render() {
const Tag = props.link ? 'a' : 'div';
return (
<Tag className="dummy"> text </Tag>
);
}
When I return div or a directly in my code, it works correctly. When I return Tag it fails!
EDIT: Open issue in Github: https://www.github.com/Microsoft/TypeScript/issues/28768
'a'isn't a React element, it's a string.const Tag = (props) => React.createElement(props.link ? 'a' : 'div', { className: "dummy" }, props.children);However this is just a simple component that you could initialize outside the class.