I have a very simple functional component as follows:
import * as React from 'react';
export interface AuxProps {
children: React.ReactNode
}
const aux = (props: AuxProps) => props.children;
export default aux;
And another component:
import * as React from "react";
export interface LayoutProps {
children: React.ReactNode
}
const layout = (props: LayoutProps) => (
<Aux>
<div>Toolbar, SideDrawer, Backdrop</div>
<main>
{props.children}
</main>
<Aux/>
);
export default layout;
I keep on getting the following error:
[ts]
JSX element type ‘ReactNode’ is not a constructor function for JSX elements.
Type ‘undefined’ is not assignable to type ‘ElementClass’. [2605]
How do I type this correctly?
2Best Answer
Just children: React.ReactNode
.