"Learning React: Props and Fragments Explained"

⚛️ React.js Day 5 — Props & React Fragments Day 5 of my React.js learning journey! Today, I explored two important topics — Props and React Fragments What are Props? Props (short for properties) are used to pass data from one component to another — usually from parent to child. Props are read-only, meaning they cannot be modified by the child component. They help make components reusable and dynamic. Example: function Welcome(props) { return <h2>Hello, {props.name}!</h2>; } function App() { return <Welcome name="Prachi" />; } Here, name is a prop passed from App to Welcome. What are React Fragments? React Fragments let you group multiple elements without adding extra nodes to the DOM. Useful when you want to return multiple elements from a component without wrapping them in a <div>. Example: function Info() { return ( <> <h3>React Fragments</h3> <p>They help avoid unnecessary HTML wrappers.</p> </> ); } <>...</> is a shorthand for <React.Fragment>. #ReactJS #ReactProps #ReactFragments #ReactLearning #ReactSeries #LearnReact #FrontendDevelopment #WebDevelopment #JavaScript #ReactDeveloper #CodeNewbie #100DaysOfCode #DeveloperJourney

To view or add a comment, sign in

Explore content categories