What are fragments in react.js?

Answer

It's a common pattern in React which is used for a component to return multiple elements.
Fragments make group a list of children without adding extra nodes to the DOM.

render() {
return (
<React.Fragment>
<ChildA />
<ChildB />
<ChildC />
</React.Fragment>
)
}

There is also a shorter syntax, but it's not supported in many tools:

render() {
return (
<>
<ChildA />
<ChildB />
<ChildC />
</>
)
}

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---