class App extends React.Component {
render() {
return (
<Header />
<Content/>
);
}
}
This code throw error as follow :
./src/App.js
Line 9: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?
7 | return (
8 |
> 9 |
| ^
10 | );
11 | }
12 | }
to solve that error that you need to put your component tags into elclosing tagslike thisreturn ( <div> <Comp1 /> <Comp2 /> </div> )
or you can use the
<React.Fragment>return ( <React.Fragment> <Comp1 /> <Comp2 /> </React.Fragment>
)https://reactjs.org/docs/fragments.html
No comments:
Post a Comment