Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.61 KB

03.Components.md

File metadata and controls

28 lines (21 loc) · 1.61 KB

An introduction to understanding components and how they work in React

In this blog post, we'll explore the concept of components in React, one of the fundamental building blocks of modern web development. We'll look at what components are, how they work, and how they can be used to build reusable and scalable web applications. Whether you're new to React or have some experience with it, this post will give you a deeper understanding of how components work and how they fit into the React ecosystem.

What are the components in the React?

"Components in React typically consist of a combination of HTML, JavaScript, and CSS. These components are designed for reuse and can be built from scratch or created by combining other components. They are essentially just JavaScript functions that return JSX, which is a syntax extension of JavaScript that allows you to write HTML-like code in your JavaScript files. Components are useful for creating modular and reusable code, and they can be an important tool for building and maintaining large applications."

Components of a Component

  • Make a component >> src >> components
  • add css file by just importing
  • function name as a component name
  • function also contains a paramter object of pros
  • function can also contains some logic
  • contain a function return some JSX
  • use className=""
  • use javascript in JSX as a {}
  • Add aslo nested components(pass props.-- into its custom attribute)
  • JSX returing wrapper element never be a Component (Build Custom Wrapper Components) for this.
import React from "react";

function Message(props) {
  return <p>{props.text}</p>;
}