This Week In React #93: Server Components, Remix, Gatsby, React-Native-Web, Perf, Immutability, Stately, TypeScript, Deno...
Tags: react, reactnative, typescript, javascript
Published: 2022-02-09 10:38:42

---
series: This Week In React
---
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](https://cf.thisweekinreact.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter). 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](https://community.cloudflare.com/t/fetch-from-aws-api-gateway-fails-from-worker-with-error-525-revealing-the-origin-url-in-error-page/51320/8?u=sebastienlorber&utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 😅.

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**](https://gist.github.com/slorber/cb732fb5d0a002c4d73236a9baeba7bb?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   😍 [**Write testimonials on Twitter**](https://twitter.com/sebastienlorber/timelines/1448942785814466561?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   🧵 [**Retweet the latest Twitter thread**](https://slo.im/thread?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   📨 **Reply to this **[**email**](mailto:lorber.sebastien@gmail.com?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)**:** feedback is welcome


[![](https://user-images.githubusercontent.com/749374/153181021-8fdb0ece-270a-4cf2-980b-4557d04316ad.png)](https://thisweekinreact.com)


## React

[**Shopify: React Server Components best practices**](https://shopify.engineering/react-server-components-best-practices-hydrogen?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

Cathryn's feedback on the usage of Servers Components at Shopify, which she learned to use through their new [Hydrogen](https://hydrogen.shopify.dev/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 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](https://twitter.com/sebmarkbage/status/1096115287781400576?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 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](https://shopify.engineering/rapid-development-hydrogen-building-product-page?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

[**How to write performant React apps with Context**](https://www.developerway.com/posts/how-to-write-performant-react-apps-with-context?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

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**](https://benadam.me/thoughts/react-svg-sprites/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

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](https://horus.dev/blog/react-native-web-remix-setup?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): React-Native-Web integrates well with Remix, as any CSS-in-JS lib.
-   📜 [Offline React Query](https://tkdodo.eu/blog/offline-react-query?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Dominik presents limits of React-Query 3 to handle offline or network issues, and introduces new v4 ([in alpha](https://github.com/tannerlinsley/react-query/releases?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)) that might help you ship better offline-first apps.
-   📜 [Rendering 3D in React made easy with react-three-fiber](https://tsh.io/blog/react-three-fiber/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): nice intro to Three.js and R3f.
-   📖 Partytown: [new doc site](https://partytown.builder.io/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) + pages to integrate with [Next.js](https://partytown.builder.io/nextjs?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) and [Remix](https://partytown.builder.io/remix?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   🐦 [*"A simple composition trick to avoid re-rendering a component"*](https://twitter.com/asidorenko_/status/1490017216942780418?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): same composition technique as the one used with Server Components 😏 (first article)
-   📦 [Gatsby 4.7](https://www.gatsbyjs.com/docs/reference/release-notes/v4.7/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): with new option: `trailingSlash`
-   📦 [Yerba](https://github.com/TheoBr/yerba?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Electron Turborepo monorepo with Next.js, Typescript, Vite...
-   📦 [Lamina](https://github.com/pmndrs/lamina?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): layer-based shader material for Three.js + React-Three-Fiber
-   🔗 [Remix Routing Demo](https://remix-routing-demo.netlify.app/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   🔗 [Remix Bug Report Test](https://twitter.com/remix_run/status/1488999703354085380?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Remix suggests to report framework bugs by creating failing tests 😏
-   🔗 [remix.guide](https://remix.guide/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): kind-of HackerNews for Remix content

## 💸 Sponsors

[**Stream: powerful Chat & Feeds for React & React-Native**](https://getstream.io/?utm_campaign=thisweekinreact&utm_content=Developer&utm_medium=email&utm_source=Revue%20newsletter)

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](https://getstream.io/chat/sdk/react/?utm_campaign=thisweekinreact&utm_content=Developer&utm_medium=email&utm_source=Revue%20newsletter), [React-Native](https://getstream.io/chat/sdk/react-native/?utm_campaign=thisweekinreact&utm_content=Developer&utm_medium=email&utm_source=Revue%20newsletter), Flutter, Android, Angular, Compose, Unreal and iOS. It also supports [Expo managed workflow](https://github.com/GetStream/stream-chat-react-native/tree/develop/examples/ExpoMessaging?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter).

Unlock enterprise-grade features, functions, and UI components **completely free** for your startup or side project with the [Maker Account](https://getstream.io/blog/maker-account/?utm_campaign=thisweekinreact&utm_content=Developer&utm_medium=email&utm_source=Revue%20newsletter).

## 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"*](https://twitter.com/acdlite/status/1489755769876754434?s=20&t=oOXVNH5yTvK-4xcWrJM7Ig&utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): 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..."*](https://twitter.com/satya164/status/1490279552882511878?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   📜 [Displaying a List in React Native: Map Method or FlatList Component](https://blog.expo.dev/react-native-flatlist-made-easy-20fca51e0327?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   📜 [Expo EAS + LogRocket: Unlimited Possibilities for Your Expo Apps](https://blog.expo.dev/eas-logrocket-unlimited-possibilities-for-your-expo-apps-d74cf1fbf1b5?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   📖 [React-Navigation - Organizing Types](https://reactnavigation.org/docs/typescript/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter#organizing-types): new doc
-   📦 [React-Native 0.68.0-rc.1](https://github.com/facebook/react-native/releases/tag/v0.68.0-rc.1?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): new branche and RC already available, as the release cycle is becoming faster
-   📦 [expo-e2e-demo](https://github.com/calitb/expo-e2e-demo?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): demo running Detox e2e tests on an Expo app with GitHub actions
-   📦 [React Location on React Native POC](https://github.com/tom-sherman/ReactLocationNative?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): integrates the React-Location lib with React-Native to enable the render-as-you-fetch pattern
-   🐦 [*"We rebuilt the docs of NativeBase using Nativebase"*](https://twitter.com/sanketsahu/status/1489588106194202627?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [👥](https://emojikeyboard.org/copy/Busts_in_Silhouette_Emoji_%F0%9F%91%A5?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) [App.js Conf 2022](https://blog.swmansion.com/app-js-conf-2022-4ad792c0a566?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): 8-10 June Krakow ([CFP](https://docs.google.com/forms/d/e/1FAIpQLScyrpH1Htd1A6oEKL6RDDMckjP7L_FmWljsAvVpu-pbLhQiJw/viewform?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)). I still have my 2020 ticket so hopefully you'll see me there 😉
-   [👥](https://emojikeyboard.org/copy/Busts_in_Silhouette_Emoji_%F0%9F%91%A5?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) [React Native London February 2022](https://www.meetup.com/React-Native-London/events/283794909/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): meetup (live stream) with Quin Jung (Expo) talking about the brand new EAS Updates
-   🎥 [Limitless App Development with Expo and React Native](https://www.youtube.com/watch?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter&v=b5ZHPJU_FLQ)

## Partners

-   [**Start React Native**](https://start-react-native.dev/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): learn everything about gestures and animations with William Candillon
-   [**React-Native Weekly**](https://andrei-calazans.com/tags/react-native-weekly?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): stay up-to-date React-Native core updates
-   [**TypeScript Weekly**](https://www.typescript-weekly.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): the best TypeScript links every week, right in your inbox.
-   [**ES.next News**](http://esnextnews.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): learn about the latest in JavaScript and cross-platform tools
-   [**Tailwind Weekly**](https://tailwindweekly.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): all things Tailwind CSS, new issue every Saturday
-   [**G2i**](https://www.g2i.co/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): pre-vetted remote React & React-Native developers you can trust on contract or full-time basis
-   [**Infinite Red**](https://infinite.red/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): US React-Native experts making your idea a reality
-   [**Software Mansion**](https://swmansion.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): the co-creators of React Native and the technological core of many tech companies

## Other

[**A list of every web API in Deno**](https://deno.com/blog/every-web-api-in-deno?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

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](https://twitter.com/MylesBorins/status/1489024782205173760?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter). Also read: [fetch() In Node.js Core: Why You Should Care](https://fusebit.io/blog/node-fetch/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter).

[**Immutability isn't free**](https://swizec.com/blog/immutability-isnt-free/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

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](https://hypirion.com/musings/understanding-persistent-vector-pt-1?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter), used internally by libs such as [ImmutableJS](https://immutable-js.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter).

[**Netlify Scheduled Functions**](https://www.netlify.com/blog/quirrel-joins-netlify-and-scheduled-functions-launches-in-beta?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

[Quirrel](https://quirrel.dev/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) (serverless cron jobs SaaS) and its creator Simon (see his [post](https://simonknott.de/articles/netlify-acquires-quirrel?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)) 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](https://github.com/blitz-js/blitz/discussions/3075?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 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](https://dev.to/this-is-learning/why-efficient-hydration-in-javascript-frameworks-is-so-challenging-1ca3?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Ryan Carniato (Solid) presents tradeoffs of various frontend apps hydration strategies, including Remix, Server Components, Astro, Qwik...
-   [Stately Editor public beta](https://stately.ai/blog/stately-editor-public-beta?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): low-code tool to create app logic visually based on state machines and state charts. By the creator of XState.
-   [Babel 7.17.0](https://babeljs.io/blog/2022/02/02/7.17.0?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): includes new decorators proposal (stage 2)
-   [@tsconfig/strictest](https://www.npmjs.com/package/@tsconfig/strictest?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): because [strict mode is not strict enough](https://twitter.com/orta/status/1489489857198051328?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Wordle with TypeScript types](https://twitter.com/orta/status/1490631626828746753?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 😝
-   [Monitor Exports from Packages in Monorepos](https://kamranicus.com/monitor-exports-from-node-js-packages-in-monorepos/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): using Jest snapshots + `codeowners` to monitor changes in libs public API surface 🤔
-   [Structuring your Storybook](https://storybook.js.org/blog/structuring-your-storybook/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   GitHub: [New sponsors-only repositories, custom amounts, and more](https://github.blog/2022-02-02-new-sponsors-only-repositories-custom-amounts-and-more/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   New option [curl --json](https://daniel.haxx.se/blog/2022/02/02/curl-dash-dash-json/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [*"Nobody at Facebook has worked on Jest for years"*](https://news.ycombinator.com/item?id=30168241&utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): some Hacker News drama
-   [Vercel - The evolution of the Web](https://vercel.com/blog/how-the-web-evolves?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): 2021 retrospective
-   [Flutter 2.10](https://medium.com/flutter/whats-new-in-flutter-2-10-5aafb0314b12?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Announcing Flutter for Windows](https://medium.com/flutter/announcing-flutter-for-windows-6979d0d01fed?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Push Notifications, WebXR, and better PWA support coming to iOS](https://firt.dev/ios-15.4b/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [A TypeScript Perspective on Go: the 2021 Advent of Code](https://effectivetypescript.com/2022/02/06/advent-of-code-2021-golang/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [DesignSystem.tools](https://www.designsystem.tools/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Vue 3 as the New Default](https://twitter.com/vuejs/status/1490592213184573441?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Chrome 99: CSS Cascade Layers, a New Picker for Input Elements, and More](https://blog.chromium.org/2022/02/chrome-99-css-cascade-layers-new-picker.html?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Electron 17](https://www.electronjs.org/blog/electron-17-0?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [*"Did ya know you probably should be using `interface` rather than `type` where possible?"*](https://twitter.com/alexdotjs/status/1489766836912668672?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Stackshare: Top 100+ Developer Tools 2021](https://stackshare.io/posts/top-developer-tools-2021?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Use Streams to Build High-Performing Node.js Applications](https://blog.appsignal.com/2022/02/02/use-streams-to-build-high-performing-nodejs-applications.html?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Using fetch(), AbortSignal, And setTimeout() To Apply Retry Mechanics In JavaScript](https://www.bennadel.com/blog/4200-using-fetch-abortsignal-and-settimeout-to-apply-retry-mechanics-in-javascript.htm?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Yes, I can connect to a DB in CSS](https://www.leemeichin.com/posts/yes-i-can-connect-to-a-db-in-css.html?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Custom Highlight API](https://twitter.com/patrickbrosset/status/1484197202461401090?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Wolvic: AR/VR browser](https://twitter.com/tomayac/status/1489256709163929606?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [When should you leverage Module Federation, and how?](https://scriptedalchemy.medium.com/when-should-you-leverage-module-federation-and-how-2998b132c840?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

[![Oreilly in bottle of wine](https://user-images.githubusercontent.com/749374/153180689-001f2669-b7a9-4e1e-898c-cbb9cef42067.png)](https://twitter.com/teej_m/status/1489491830580264960)