Huement - Blog & News Aggregator
Featured Blog Article Posts
Latest Article
Modern React Based Shopify Storefront - Server side NextJS rendering and Reduced Motion support for mobile
Part 1 - Core React Concepts
This article explores how a modern React + Next.js storefront leverages the newest React patterns and architecture to deliver an interactive, accessible, animation-rich ecommerce experience. Instead of discussing React in theory, we examine real production components:
- Root Layout
- Product Grid
- Quick View Modal
Each demonstrates modern React concepts including JSX, client/server boundaries, hooks, component composition, portals, context, animation orchestration, and accessibility-driven UI design. Before we dive in, lets take a minute to make sure we are all on the same page. React officially shifted its focus from Class components to Functional components on February 6, 2019, with the release of React 16.8.
Functional Components
Modern React shifted the paradigm from Class Components (which act like blueprints for objects) to Functional Components (which act like pure JavaScript functions). This isn't just a syntax preference; it changed the entire architecture of frontend development.
Summary Table: Class vs. Functional
| Feature | Class Components [OLD] | Functional Components [NEW] |
|---|---|---|
| State | this.state / this.setState | useState Hook |
| Logic Reuse | HOCs, Render Props | Custom Hooks |
| Lifecycle | componentDidMount, etc. | useEffect Hook |
| Complexity | High (due to this context) | Low (pure JavaScript functions) |
| Logic Grouping | Logic grouped by time (Lifecycle). | Logic grouped by concern (Feature). |
To illustrate the shift, let’s look at a common scenario: a component that tracks a window's width and manages a simple counter. In the Class version, the logic for the window listener is split across thr...