React 18 and data-fetching options

React's team laid out its release plan for React 18 with an alpha already available and a beta some months off. Of the write-ups on the announcement, Cassidy's stood out for clarity on the parts most developers will care about.

On the data side, React Query bills itself as the missing data-fetching library for React, and its clear documentation and DevTools make it appealing. It even looks more popular than Apollo. Apollo remains a reasonable pick for teams working heavily with GraphQL, though its biggest drawback is unclear error reporting. A third alternative, RTK Query, is examined by Matt Stobbs. As he puts it, a typical Redux store mixes backend data—which is really acting as a cache—with UI state that isn't persisted across reloads, and treating both the same makes each more complicated.

Lazy loading and lazy properties

Dan Laush surveyed the modern options for conditional and lazy-loading JavaScript, territory that is more complicated than it ought to be but is improving. Suspense in React 18 and top-level await both help, and Astro handles this well through partial hydration. Nicholas C. Zakas' "The lazy-loading property pattern in JavaScript" is also worth reading: it offers a neat way to define objects that perform expensive work only once, when first asked, then replace the property on themselves with the result.

JSX is often thought of as a React feature, but it stands apart and can serve other frameworks such as Preact and Vue, or even work with no framework at all—something we covered in an earlier video. Andrea Giammarchi goes deep on how JSX can combine with template literals to get rid of a lot of unnecessary syntax noise, with runnable examples:

You can see it working in CodePen via uhtml, uland, ube, or lit-html.

Keeping components consolidated

Kent Dodds' take on compound components with React Hooks has found a home in CodePen's pattern library. Each part is tied to the shared object, so individual pieces don't need extra props passed in by hand, which keeps components consolidated instead of sprawling into trees of similarly named sub-components with custom state sharing.

JavaScript fundamentals and lightweight alternatives

Jake Archibald wrote the go-to explanation of this. On readability, Laurie Barth compared code samples that are functionally identical to show how much their legibility varies. Often there's no single right answer, but, as she writes, "when you're looking at code that is functionally identical, your determination should be based on humans—how humans consume code."

petite-vue is a slimmed-down Vue offering an alternative to Alpine.js for sprinkling interactivity onto existing pages without committing to a full framework.