Last active
March 25, 2021 21:18
-
-
Save carlitorweb/72dda9c9238e3fb10aa87bb1e6d90699 to your computer and use it in GitHub Desktop.
In the file "Layout", <Aux> still complaining with Typescript: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AUX FILE | |
import React from "react"; | |
interface AuxProps { | |
children: React.ReactNode; | |
} | |
const aux = (props: AuxProps) => <>{props.children}</>; | |
export default aux; | |
------------------------- | |
// LAYOUT FILE | |
import React from "react"; | |
import Aux from "../../hoc/auxiliar"; | |
interface LayoutProps { | |
children: React.ReactNode; | |
} | |
const layout = (props: LayoutProps) => ( | |
<Aux> | |
<div>Toolbar, SideDrawer, Backdrop</div> | |
<main>{props.children}</main> | |
</Aux> | |
); | |
export default layout; |
Needed use Fragment, since for the moment, this is unfortunately a limitation of the compiler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the file "Layout", still complaining with Typescript: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided.
And is true, wrap a JSX element and a children element. But I do not know how put the correct type for him. Any hint?