Components :
- In react , components is a reusable and independent piece of UI .
- Think of its like a function or building block that return html with javascript logic.
Components make your code modular , reusable and easy to maintain.
Types of components :functional components
-
class components
Example:
function Welcome(props) {
returnHello, {props.name}!
; }
function App() {
return (
);
}
Props:
- props stands for properties.
- they are like function parameters in javascript
- props are used to pass data from parent componts to child component.
- props are read-only .child can not modify them.
Example:
function Child(props) {
return
My favorite color is {props.color}
; }
function Parent() {
return ;
}
Top comments (0)