I want to define class in React with Typescript which has a method with html output. but get error about output type of function.
interface StateProps {
page: string,
}
class App extends React.Component<StateProps,any> {
render() {
return (
<div className="App">
{this.pageContent(this.props.page)}
</div>
);
}
pageContent = (page:string) => {
switch (page) {
case "newPage":
return <NewPage />;
case "otherPage":
return <OtherPage />;
default:
break;
}
}
}
error was:
Type 'void' is not assignable to type 'ReactNode'.
eslint suggest use DetailedHTMLProps<HtmlAttributes<HTMLDivElement>,HTMLDivElement> but it didnt work.