Home
About Us
Contact Us
Bookmark
Saved Bookmarks
Current Affairs
General Knowledge
Chemical Engineering
UPSEE
BSNL
ISRO
BITSAT
Amazon
ORACLE
Verbal Ability
→
Web Development
→
Bootstrap in Web Development
→
What is known as Fragment in React.
1.
What is known as Fragment in React.
Answer»
How to return multiple components
WITHOUT
wrapping using
DIV
, HOC or Fragment
Fragments help you return a
LIST
of items without adding extra nodes to the DOM.
Return as an Array. This is introduced since React 16
import React from "react"; import ReactDOM from "react-dom"; import "./styles.css"; function App() { return ( [ <
P
&
GT
;one</p>, <p>two</p> ] ); } const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement);
Show Answer
Discussion
No Comment Found
Post Comment
Related InterviewSolutions
What are Pure Functions and how they are used in reducers?
What is the difference between this.state.name=”Thomas” and this.setState({name: “Thomas”}) ?
Explain type-checking with PropTypes in React?
Explain Fragments in React 16?
Explain the use of Webpack and Babel in ReactJS?
Explain “refs” in React?
How to use a library like jQuery in React, which interacts directly with DOM?
Explain Virtual DOM in React?
What is state in React?
What are props in React?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies