Lädt...


🔧 React - Components


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Buliding Blocks

Reusable

n React, components are the building blocks of a user interface. A component is a self-contained piece of code that defines a part of the UI and its behavior. Components can be reused and combined to create complex user interfaces.

Types of Components
Functional Components ( state less components)

These are simple JavaScript functions.
They take input (called props) and return JSX.
Example:
jsx
Copy code
function Greeting(props) {
return

Hello, {props.name}!

;
}

// Usage

Class Components ( state components)

These are ES6 classes that extend React.Component.
They have more advanced features, such as lifecycle methods and state.
Example:
jsx
Copy code
class Greeting extends React.Component {
render() {
return

Hello, {this.props.name}!

;
}
}

// Usage

Features of Components
Reusability

Components can be reused across the application, making your code more organized and modular.
Props (Properties) - default {obj}

Props are inputs passed to components to make them dynamic.
Example:
jsx
Copy code
function Welcome(props) {
return

Welcome, {props.user}!

;
}
State

State is used to store data inside a component. It can change over time.
Example:
jsx
Copy code
function Counter() {
const [count, setCount] = React.useState(0);

return (


Count: {count}


setCount(count + 1)}>Increase

);
}
Composition

Components can contain other components to build complex UIs.
Example:
jsx
Copy code
function App() {
return (






);
}
Why Use Components?
Maintainability: Keeps your code clean and easy to debug.
Reusability: Write once and use multiple times.
Modularity: Breaks down a large UI into smaller, manageable parts.
Scalability: Makes it easier to scale applications as the codebase grows.

function

function App() {

let user ="Ranjith";

return (

<>

{/* function call /}
{/
*/}

{/* props */}

{/* component call */}
    {/* <Footer/> */}

{/*props */}
    <Footer user ="srt"/>

<Content/>


</>

);

}

export default App;

EX :

function Header() {
return (

Todo List



);
}

class

import React from "react"; //react library

// c.name inheritance component
class Footer extends React.Component {
// class function
render() {

   console.log(this.props);

return (
  <footer>
    <h2>footer</h2>
  </footer>
)

}
}

export default Footer;

...

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.35 Punkte
🔧 Programmierung

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.35 Punkte
🔧 Programmierung

🔧 Level Up React : React and React DOM architecture


📈 16.76 Punkte
🔧 Programmierung

🔧 Create an SSR Application with Vite, React, React Query and React Router


📈 16.76 Punkte
🔧 Programmierung

🔧 Building CRUD App with react-form, zod, react data grid, react-query and json-server


📈 16.76 Punkte
🔧 Programmierung

🔧 Navigating with React Router React Js Part 4: A Guide to Routing in React Applications


📈 16.76 Punkte
🔧 Programmierung

🔧 Dynamic Manipulation of Children in React JSX with React.cloneElement and React.Children.map


📈 16.76 Punkte
🔧 Programmierung

🔧 Handling React OTP Input Auth Web | React Native using react-otp-kit package


📈 16.76 Punkte
🔧 Programmierung

🔧 Handling React OTP Input Auth Web | React Native using react-otp-kit package


📈 16.76 Punkte
🔧 Programmierung

🔧 What’s New in React 19? React Canaries, Actions, and React Compiler


📈 16.76 Punkte
🔧 Programmierung

🔧 Reactotron: debugging tool for React & React Native


📈 11.17 Punkte
🔧 Programmierung

🔧 This Week In React #174: ReactLabs, React-Strict-DOM, Remix, RNGH, Expo, RN+TV, TC39, Vite...


📈 11.17 Punkte
🔧 Programmierung

🔧 React with TypeScript: Advanced Techniques (Compatible with React 19) 🚀


📈 11.17 Punkte
🔧 Programmierung

🔧 Routing in React with React Router Dom


📈 11.17 Punkte
🔧 Programmierung

🔧 Mastering React Router: The Ultimate Guide to Navigation and Routing in React Apps!


📈 11.17 Punkte
🔧 Programmierung

🔧 The State of React Native Tooling (React Native CLI - The Ultimate Guide)


📈 11.17 Punkte
🔧 Programmierung

🔧 Gerenciamento de Formulários Complexos em React com React Hook Form


📈 11.17 Punkte
🔧 Programmierung

🔧 Implement React v18 from Scratch Using WASM and Rust [16] Implement React Noop


📈 11.17 Punkte
🔧 Programmierung

🔧 React 19 vs React 18: Performance Improvements and Migration Guide


📈 11.17 Punkte
🔧 Programmierung

🔧 Main concept of react || React


📈 11.17 Punkte
🔧 Programmierung

🔧 How to Build a Dynamic Dropdown Component in React – React Compound Component Pattern Explained


📈 11.17 Punkte
🔧 Programmierung

🔧 Introducing SciChart-React: An OSS Library for React Charts With SciChart.js


📈 11.17 Punkte
🔧 Programmierung

🔧 Kickstart Your React Journey: How to Create Your First React App!


📈 11.17 Punkte
🔧 Programmierung

🔧 Unlocking React's Power: Understanding React's Core Hooks


📈 11.17 Punkte
🔧 Programmierung

🔧 Что такое React Fiber - React Fiber Architecture


📈 11.17 Punkte
🔧 Programmierung

🔧 Mastering React Query. Simplifying Data Management in React with Separation Patterns


📈 11.17 Punkte
🔧 Programmierung

matomo