[go: up one dir, main page]

0% found this document useful (0 votes)
40 views4 pages

React TakeOff Workshop Guide

The React TakeOff Workshop Guide provides an overview of React, a JavaScript library for building user interfaces, covering key concepts such as components, props, state, and hooks. It also includes practical examples of handling events, conditional rendering, and routing, as well as deployment options. The guide emphasizes best practices like composition over inheritance and using the Context API for global state management.

Uploaded by

hello.softworica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

React TakeOff Workshop Guide

The React TakeOff Workshop Guide provides an overview of React, a JavaScript library for building user interfaces, covering key concepts such as components, props, state, and hooks. It also includes practical examples of handling events, conditional rendering, and routing, as well as deployment options. The guide emphasizes best practices like composition over inheritance and using the Context API for global state management.

Uploaded by

hello.softworica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

React TakeOff Workshop Guide

Introduction to React

React is a JavaScript library for building user interfaces. It is component-based, developed by Meta (formerly

Facebook), and supports single-page applications using the virtual DOM.

JSX and Rendering

JSX allows combining JavaScript and HTML-like syntax:

const element = <h1>Hello, world!</h1>;

ReactDOM.render(element, document.getElementById('root'));

Components (Function vs Class)

Function component:

function Welcome(props) {

return <h1>Hello, {props.name}</h1>;

Class component:

class Welcome extends React.Component {

render() {

return <h1>Hello, {this.props.name}</h1>;

Props and State

Props are passed from parent to child. State is local and mutable:

function Greeting({ name }) {

return <h2>Welcome, {name}!</h2>;

}
React TakeOff Workshop Guide

Handling Events

React handles events similarly to DOM:

function MyButton() {

const handleClick = () => alert('Clicked!');

return <button onClick={handleClick}>Click Me</button>;

Conditional Rendering

Conditional logic inside JSX:

{isLoggedIn ? <Dashboard /> : <Login />}

Lists and Keys

Rendering lists:

const todos = ['Learn', 'Build'];

todos.map((todo, i) => <li key={i}>{todo}</li>)

useState Hook

useState allows local component state:

const [count, setCount] = useState(0);

useEffect Hook

useEffect runs side-effects:

useEffect(() => { document.title = `Count: ${count}`; }, [count]);

Forms in React

Controlled form input:

<input value={name} onChange={e => setName(e.target.value)} />


React TakeOff Workshop Guide

Lifting State Up

Shared state lives in parent and is passed down:

<Child value={value} onChange={setValue} />

Composition vs Inheritance

Use composition over inheritance:

<Card title='Welcome'>{content}</Card>

React Router Basics

Routing with react-router:

<Route path='/about' element={<About />} />

React Context API

Global state using context:

<ThemeContext.Provider value='dark'><App /></ThemeContext.Provider>

Custom Hooks

Encapsulate logic:

function useCounter() {

const [count, setCount] = useState(0); return { count, increment: () => setCount(c => c + 1) }; }

Error Boundaries

Class components catch errors:

class ErrorBoundary extends React.Component { ... }

Code Splitting / Lazy Loading

Dynamic import with React.lazy and Suspense:

<Suspense fallback={<div>Loading</div>}><LazyComponent /></Suspense>


React TakeOff Workshop Guide

Styling in React

Options: CSS Modules, Tailwind, inline styles, styled-components

Project Structure

/src/components, /hooks, /pages, App.jsx

Deployment

Netlify, Vercel, or GitHub Pages using npm run build

You might also like