Concept

Components and Props

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. The simplest way to define a component is to write a JavaScript function

const Welcome = (props) => <h1>Hello, {props.name}</h1>

Also, you can define it in classes. We can pass properties through an object called props. You can also pass other components and split them into smaller components like this:

const Header = () => <header>Header</header> const Main = (props) => <main>Hello {props.name} 🏈</main> const Footer = () => <footer>Footer</footer> const Page = () => <div> <Header/> <Main name={'Jimy'}/> <Footer/> </div>

0

1

Updated 2023-03-23

Tags

JavaScript Programming Language

1Cademy

Object-Oriented Programming

Programming Language Paradigms

General programming languages

Computing Sciences