0 day streak
javascript / beginner
Snippet

Functional Components and Props

In React, functional components are JavaScript functions that return JSX. 'Props' (short for properties) are used to pass data from a parent component to a child component, making the component reusable.

snippet.js
javascript
1
2
3
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
react
Breakdown
1
function Welcome(props)
Defines a component named 'Welcome' that accepts an object called 'props'.
2
{props.name}
Uses curly braces to embed the 'name' property from the props object into the HTML.