Skip to content

Instantly share code, notes, and snippets.

@carlitorweb
Last active March 25, 2021 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlitorweb/72dda9c9238e3fb10aa87bb1e6d90699 to your computer and use it in GitHub Desktop.
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.
// 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;
@carlitorweb
Copy link
Author

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?

@carlitorweb
Copy link
Author

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