Hi everyone!
Many great articles this week, in particular a very first pragmatic feedback on using Server Components at Shopify.
Newsletter is late this week because I'm trying to create a landing page for it:Β cf.thisweekinreact.com. I'm using a brand new stack (Remix, Tailwind, Cloudflare Pages), but I have some SSL issues andΒ Cloudflare refuses to communicate with Revue APIΒ π .
I'm also using more emojis to "categorize" links. Please let me know if you find this useful π€·ββοΈ?
πΒ Support the newsletter:
- πΒ Recommend it to your friends: it really helps!
- πΈΒ Sponsorise This Week In React
- πΒ Write testimonials on Twitter
- π§΅Β Retweet the latest Twitter thread
- π¨Β Reply to thisΒ email:Β feedback is welcome
React
Shopify: React Server Components best practices
Cathryn's feedback on the usage of Servers Components at Shopify, which she learned to use through their newΒ HydrogenΒ framework. Without best practices, you might not leverage this new React feature properly and end-up with a bundle larger than it could be.
She advises to use Shared Components by default, instead of Client Components (what we use today). For interactivity, extract some Client Components with the finest granularity. Then try to convert the rest to Server Components if it's possible. The composition patterns (usage ofΒ children
) thatΒ we sometimes use to optimizeΒ can also be used to interleave components of different types.
She offers a real decision tree, which she illustrates with 2 examples: newsletter signup and product FAQ.
A Shopify tutorial using server components has also been published:Β Rapid Development with Hydrogen: Building a Product Page
How to write performant React apps with Context
Nadia explains how you can optimize rendering on a complex React form using the React context. First, you have to separate into 2 contexts and hooksΒ useFormData()
Β andΒ useFormAPI()
. Do not forget to memorize properly theΒ api
Β object. We can eventually split the state into several smaller contexts.
These techniques may not scale as well as a real state manager, but are still useful to know in case you can't use one.
The "best" way to manage icons in React.js
There are many ways to use icons in React, each with different tradeoffs.
.svg
Β files cannot be styled in CSS. React components that render SVG (also applies to SVGR) are convenient, but they inline the SVG markup in the HTML output and makes the page heavier. In my experience, we see this problem very quickly on a static pages (or SSR) that uses the same icon many times.
Ben offers a great, lesser-known alternative: using SVG sprites.
Extras:
- πΒ How to Setup React Native Web in a Remix project: React-Native-Web integrates well with Remix, as any CSS-in-JS lib.
- πΒ Offline React Query: Dominik presents limits of React-Query 3 to handle offline or network issues, and introduces new v4 (in alpha) that might help you ship better offline-first apps.
- πΒ Rendering 3D in React made easy with react-three-fiber: nice intro to Three.js and R3f.
- π Partytown:Β new doc siteΒ + pages to integrate withΒ Next.jsΒ andΒ Remix
- π¦Β "A simple composition trick to avoid re-rendering a component": same composition technique as the one used with Server Components π (first article)
- π¦Β Gatsby 4.7: with new option:Β
trailingSlash
- π¦Β Yerba: Electron Turborepo monorepo with Next.js, Typescript, Vite...
- π¦Β Lamina: layer-based shader material for Three.js + React-Three-Fiber
- πΒ Remix Routing Demo
- πΒ Remix Bug Report Test: Remix suggests to report framework bugs by creating failing tests π
- πΒ remix.guide: kind-of HackerNews for Remix content
πΈ Sponsors
Stream: powerful Chat & Feeds for React & React-Native
Stream is the maker of enterprise-gradeΒ APIsΒ andΒ SDKsΒ that help product and engineering teams solve two common problems at scale:Β in-app chatΒ andΒ social activity feeds.
With Stream, developers can integrate any type of messaging or feed experience into their app in a fraction of the time it would take to build these features from scratch.Β Stream Chat makes it easy for developers to integrate rich, real-time messaging into their applications.
Stream provides robust client-side SDKs for popular frameworks such asΒ React,Β React-Native, Flutter, Android, Angular, Compose, Unreal and iOS. It also supportsΒ Expo managed workflow.
Unlock enterprise-grade features, functions, and UI componentsΒ completely freeΒ for your startup or side project with theΒ Maker Account.
React-Native
- π§΅Β Andrew Clark:Β "I can't prove this but I suspect if someone built a Next.js/Remix/etc for React Native (i.e. single codebase for client and server) they would make a trillion dollars": I don't know exactly what Andrew has in mind, but this is a very interesting topic to discuss! I'm particularly interested in the usage of Server Components in React-Native (or at least some Server-Driven UI) and co-locating data requirements with screens (think Remix/
loader
, Next.js/getServerProps
 but for React-Navigation) - 𧡠Satyajit Sahoo: "Seeing many people compare React Navigation to React Router..."
- πΒ Displaying a List in React Native: Map Method or FlatList Component
- πΒ Expo EAS + LogRocket: Unlimited Possibilities for Your Expo Apps
- πΒ React-Navigation - Organizing Types: new doc
- π¦Β React-Native 0.68.0-rc.1: new branche and RC already available, as the release cycle is becoming faster
- π¦Β expo-e2e-demo: demo running Detox e2e tests on an Expo app with GitHub actions
- π¦Β React Location on React Native POC: integrates the React-Location lib with React-Native to enable the render-as-you-fetch pattern
- π¦Β "We rebuilt the docs of NativeBase using Nativebase"
- π₯Β App.js Conf 2022: 8-10 June Krakow (CFP). I still have my 2020 ticket so hopefully you'll see me there π
- π₯Β React Native London February 2022: meetup (live stream) with Quin Jung (Expo) talking about the brand new EAS Updates
- π₯Β Limitless App Development with Expo and React Native
Partners
- Start React Native: learn everything about gestures and animations with William Candillon
- React-Native Weekly: stay up-to-date React-Native core updates
- TypeScript Weekly: the best TypeScript links every week, right in your inbox.
- ES.next News: learn about the latest in JavaScript and cross-platform tools
- Tailwind Weekly: all things Tailwind CSS, new issue every Saturday
- G2i: pre-vetted remote React & React-Native developers you can trust on contract or full-time basis
- Infinite Red: US React-Native experts making your idea a reality
- Software Mansion: the co-creators of React Native and the technological core of many tech companies
Other
A list of every web API in Deno
Luca (Deno contributor) mentions exhaustively all the web APIs supported by Deno. No surprise it's a good platform to deploy Remix applications.
This is probably in response to theΒ new web APIs announced last week for Node.js 18. Also read:Β fetch() In Node.js Core: Why You Should Care.
Funny story, in a backend context but largely applicable to React apps. The usage of FP and immutability led to bad performances related to array copying and anΒ O(n2)
Β algorithm. Moving back to mutable code significantly increased the performances.
Note: it is also possible to get better performances with immutability by usingΒ vector tries and structural sharing, used internally by libs such asΒ ImmutableJS.
QuirrelΒ (serverless cron jobs SaaS) and its creator Simon (see hisΒ post) both join Netlify, which introduced a new Scheduled Functions feature in beta.
This kind of feature is clearly lacking in the current serverless landscape. Note that Blitz (Simon is a contributor)Β pivots to Blitz ToolkitΒ to provide similar services. We couldn't be surprised to see Vercel make an offer π
Extras:
- Why Efficient Hydration in JavaScript Frameworks is so Challenging: Ryan CarniatoΒ (Solid) presents tradeoffs of various frontend apps hydration strategies, including Remix, Server Components, Astro, Qwik...
- Stately Editor public beta: low-code tool to create app logic visually based on state machines and state charts. By the creator of XState.
- Babel 7.17.0: includes new decorators proposal (stage 2)
- @tsconfig/strictest: becauseΒ strict mode is not strict enough
- Wordle with TypeScript typesΒ π
- Monitor Exports from Packages in Monorepos: using Jest snapshots +Β
codeowners
Β to monitor changes in libs public API surface π€ - Structuring your Storybook
- GitHub:Β New sponsors-only repositories, custom amounts, and more
- New optionΒ curl --json
- "Nobody at Facebook has worked on Jest for years": some Hacker News drama
- Vercel - The evolution of the Web: 2021 retrospective
- Flutter 2.10
- Announcing Flutter for Windows
- Push Notifications, WebXR, and better PWA support coming to iOS
- A TypeScript Perspective on Go: the 2021 Advent of Code
- DesignSystem.tools
- Vue 3 as the New Default
- Chrome 99: CSS Cascade Layers, a New Picker for Input Elements, and More
- Electron 17
- "Did ya know you probably should be usingΒ
interface
Β rather thanΒtype
Β where possible?" - Stackshare: Top 100+ Developer Tools 2021
- Use Streams to Build High-Performing Node.js Applications
- Using fetch(), AbortSignal, And setTimeout() To Apply Retry Mechanics In JavaScript
- Yes, I can connect to a DB in CSS
- Custom Highlight API
- Wolvic: AR/VR browser
- When should you leverage Module Federation, and how?
Top comments (0)