Could not multi components was rendered to body of document?
See original GitHub issueHi, there
I’m rewriting my blog using preact, and I found returning multi components to document, console occurs error: nents/app.js: Adjacent JSX elements must be wrapped in an enclosing tag My code is below:
export default class App extends Component { render() { return ( <Header/> <Content/> ); } }
Before all components was rendered, it must be wrapped <div> or other elements?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Rendering components directly warning - Stack Overflow
The warning you are getting comes when you try to render directly within document.body. However, the code in your index.js is the correct...
Read more >7 The global structure of an HTML document - W3C
Certain HTML elements that may appear in BODY are said to be "block-level" while others are "inline" (also known as "text level"). The...
Read more >Advanced Features: Custom `Document` - Next.js
A custom Document can update the <html> and <body> tags used to render a Page. This file is only rendered on the server,...
Read more >ASP.NET Core Blazor layouts - Microsoft Learn
Every folder of an app can optionally contain a template file named ... The Episodes component is rendered where @Body appears in the ......
Read more >markdown-to-jsx - npm
</Markdown>, document.body); /* renders: <h1>Hello world!</h1> */. * NOTE: JSX does not natively preserve newlines in multiline text.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s on the ToDo list, but extremely difficult given Preact’s current design.
I’d mention that React 16.2 adds a special
React.Fragment
export with slightly different semantics from vanilla arrays. React fragments can be keyed which is handy for returning “tuples” frommap
.The plan is to have JSX compile
<>
to<React.Fragment>
, but there’s a Babel pragma you can change (e.g. Preact could providePreact.Fragment
instead).