Reactjs – TypeScript and React – children type

jsxreactjstypescripttypescript2.0

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?

Best Answer

Just children: React.ReactNode.