The Wrapped State Setter Pattern
A guide to the 'Wrapped State Setter' pattern in React for extending setState functionality, like automatic localStorage persistence.
Kyle Shevlin is a software engineer based in Portland, Oregon, who cares deeply about quality in code, writing, and craftsmanship. He focuses on continually improving his skills and helping other developers do the same, while balancing his professional life with competitive golf, gaming, and community-driven learning.
128 articles from this blog
A guide to the 'Wrapped State Setter' pattern in React for extending setState functionality, like automatic localStorage persistence.
Explains parametric design in web development: using adjustable inputs to dynamically modify visual elements like button styles.
Explores how using code folding in editors can help developers write cleaner, more readable code by evaluating its structure at different abstraction levels.
A developer shares his journey building a custom course platform to teach programming concepts like Array.reduce(), detailing his tech stack and motivations.
A developer proposes using a facade pattern to wrap third-party UI library components, explaining the benefits for flexibility and maintainability.
Explains JavaScript factory functions, their use in creating objects, and how they can replace classes with private state via closures.
A guide to fixing React Context performance issues by avoiding poor component composition patterns that cause unnecessary re-renders.
A technical comparison of React's useRef and useState hooks, explaining their distinct purposes and when to use each.
Explains JavaScript closures, showing how functions can expose and manage private internal state through their return values.
Explains why using function updaters in React state setters is better than relying on external dependencies, improving performance and reducing bugs.
Explains how to use dependency injection with default parameters in JavaScript to create more flexible and robust functions.
Explains how destructuring breaks TypeScript's discriminated union type narrowing and offers workarounds.
Argues for using declarative state updater functions in React instead of inline 'naked state setters' for better code clarity and maintainability.
A React developer shares personal opinions on structuring projects, advocating for single-file components and avoiding unnecessary sub-folders.
Explains what 'magic values' are in programming and provides examples of how to replace them with named constants for better code clarity.
Explains why using `useMemo` to create a stable handlers object is preferable to multiple `useCallback` hooks in custom React hooks.
Explores how symbolic logic principles from philosophy and math apply directly to software engineering and programming.
An introductory primer on Set Theory, explaining fundamental concepts like unions, intersections, and differences with practical JavaScript code examples.
Explains the concept of tuples in programming, their use in JavaScript, and how they differ from arrays, with examples including React hooks.
Explains how to conditionally call React hooks by using a renderless component pattern, a useful technique for React developers.