React Concepts

All React Concepts

All about useEffect

React Ecosystem Mental Map

Visual guide to modern React development

1

The Core React Trident

PRONG 1: COMPONENTS

  • Function Components (Modern Standard)
  • Class Components (Legacy)
  • JSX Syntax & Rules

PRONG 2: STATE & DATA FLOW

  • State (useState Hook)
  • Props (Passing Data Down)
  • Immutability

PRONG 3: LIFECYCLE & SIDE EFFECTS

  • useEffect Hook (Data fetching, subscriptions)
  • useLayoutEffect Hook (DOM mutations)
2

The Advanced Reef

STATE MANAGEMENT

  • Context API (useContext) for Prop Drilling
  • Redux Toolkit (Official)
  • Zustand, Jotai

ROUTING

  • React Router DOM (Client-Side Routing)

STYLING

  • CSS-in-JS (Styled-components, Emotion)
  • CSS Modules
  • Utility-First (Tailwind CSS)

DATA FETCHING & CACHING

  • fetch API, axios
  • TanStack Query (React Query) - Server State

PERFORMANCE

  • React.memo (Component Memoization)
  • useMemo (Value Memoization)
  • useCallback (Function Memoization)
  • Code Splitting & Lazy Loading (React.lazy, Suspense)
3

Framework Archipelago

NEXT.JS (VERCEL ISLAND)

  • Core Concepts: SSR, SSG, ISR
  • App Router (New paradigm: app/ directory)
  • React Server Components (RSCs)
  • Server Actions
  • File-based Routing, Layouts, Loading States
  • Pages Router (Traditional)

REMIX (SHOPIFY ISLAND)

  • Core Philosophy: Web Fundamentals
  • Nested Routing & Data Loading
  • Form Handling with Actions
  • Shared Routes

GATSBY (CONTENT ISLAND)

  • Core Strength: Static Site Generation (SSG)
  • GraphQL Data Layer
  • Ideal for Blogs, Marketing Sites, Documentation
4

The Surrounding Sea

PACKAGE MANAGEMENT

  • npm, yarn, pnpm

BUILD TOOLS

  • Vite (Modern, Fast)
  • Create React App (Legacy)
  • Parcel

DEVELOPMENT

  • React DevTools
  • Strict Mode

TESTING

  • Jest (Unit)
  • React Testing Library (Component)

TYPESCRIPT

  • Static Typing for Scalability

 

ES6 borned on 2015 Key Milestones:

  • 1997: ES1 – First edition

  • 1998: ES2

  • 1999: ES3 – Major features

  • 2009: ES5 – “Modern” JavaScript

  • 2013: React released (used ES5)
  •  
  • June 2015: ES6/ES2015 – HUGE update
  • 2015: ES6 released

  • 2015-2016: React started adopting ES6 features

  • 2016+: ES2016, ES2017, etc. (Yearly updates)

  • 2019: React Hooks released (heavily uses ES6+ features)

ES6 new features after 2015

class ProductComponent extends React.Component {  // 👈 Inheritance
    constructor(props) {
        super(props);  // Must call parent constructor
        this.state = { products: [] };
    }
    
    componentDidMount() {  // 👈 Override lifecycle method
        // Like @PostConstruct
    }
    
    componentWillUnmount() {  // 👈 Override lifecycle method  
        // Like @PreDestroy
    }
    
    render() {  // 👈 Required override
        return <div>Content</div>;
    }
}

Main Hooks You MUST Know:

1. useState – For State Management

jsx
// Like having instance variables in a class
const [products, setProducts] = useState([]);
const [loading, setLoading] = useState(false);

// Equivalent to:
// private List<Product> products = new ArrayList<>();
// private boolean loading = false;

2. useEffect – For Side Effects

jsx
// Like @PostConstruct + cleanup
useEffect(() => {
    // Component mounted - fetch data
    fetchProducts();
    
    return () => {
        // Component will unmount - cleanup
        // Like @PreDestroy
    };
}, []); // Dependency array - like method parameters

3. useContext – For Dependency Injection

jsx
// Similar to @Autowired in Spring
const userService = useContext(UserServiceContext);
// vs Spring: @Autowired UserService userService;

 

All About useEffect Hook

Back to top

use effect hook callback functions replace react component methods for overriding