This Week In React #94: 2 years 🥳️, memoization, composition, Remix, Next.js, Gatsby, React-Native, Windows, CSS, TypeScript...
Tags: react, reactnative, javascript, typescript
Published: 2022-02-16 09:49:43


---
series: This Week In React
---
Hi everyone!

The English version of this newsletter only started recently, but still... 🥳️ this week I'm celebrating the **2nd anniversary of this newsletter** 🥂, considering the [very first French edition](https://www.getrevue.co/profile/sebastien-lorber/issues/react-hebdo-sebastien-lorber-1-226366?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) was sent 2 years ago.

I'm preparing a Remix website. **That would be awesome if you could write me a public testimonial on Twitter or LinkedIn.** I will need some for the upcoming landing page, to convince potential subscribers with social proof 😏.

I already have some great feedback (thanks 🙏), but those are mostly replies, reshares, comments. I'd like to collect a few public testimonials (ability to link to them) where you explain why you like this newsletter, and where the text can be well-understood in isolation: this is best fit for a landing page.

In case you want to know more about the story behind this newsletter, I created an [Indie Hacker](https://www.indiehackers.com/product/french-react-newsletter?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) page where I build in public. I plan to update it every month.

🙏 **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

[**Using global memoization in React**](https://thoughtspile.github.io/2022/02/09/react-global-memo/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

Vladimir explains that sometimes `useMemo` is not enough, and we need to share cached data between multiple components. He suggests 5 ways to cache data in a global way outside React components, from a single constant to a LRU cache.

My opinion: using [WeakMap](https://javascript.info/weakmap-weakset?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) could also be a nice solution, and why not provide the cache inside a React context.

[**React component as prop: the right way™️**](https://www.developerway.com/posts/react-component-as-prop-the-right-way?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

Nadia gives good reasons to use React composition. She uses a button with text + icon as an example, suggest 3 alternatives and compare them under different update scenarios:

-   `icon={<MyIcon/>}`
-   `Icon={MyIcon}`
-   `renderIcon={(...settings) <Icon {...settings}/>}`

I don't like much the 1st one, and try to avoid `cloneElement` whenever I can.

**Extras:**

-   📜 [Remix upload to S3](https://www.canrau.com/en/remix-upload-to-s3?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): using a Remix API to forward an upload stream directly to S3
-   📦 [Remix Electron](https://github.com/itsMapleLeaf/remix-electron?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Remix and Electron integration 🤔 seems interesting to reduce Electron boilerplate and provide better co-location of web + native code.
-   📦 [Griffel](https://github.com/microsoft/griffel?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Microsoft's take on [atomic CSS-in-JS](https://sebastienlorber.com/atomic-css-in-js?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter), zero-runtime, typesafe. Reminds that we are still waiting for StyleX😏
-   📦 [Jotai 1.6](https://twitter.com/dai_shi/status/1492132198375657474?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): expose store interface, atom sync with localStorage...
-   🗳 [Next.js Developer Survey](http://vercel.link/nextjs-survey?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): official Vercel survey
-   💡 [Next.js RFC: Switchable Runtime](https://github.com/vercel/next.js/discussions/34179?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): SSR in Next.js is historically based on a Node.js runtime. They plan to introduce a global and per-route config to enable the Edge runtime. This is interesting in many ways: enable streaming SSR, lower latency... Note that Remix already has this somehow thanks to its adapter layer.
-   💡 [Gatsby RFC: Ahead of Time Compilation for config files](https://github.com/gatsbyjs/gatsby/discussions/34613?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): to support config files in TypeScript. FYI I found an interesting package for this use-case [bundle-require](https://github.com/egoist/bundle-require?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   💡 [Flat file system for file-based routing](https://gist.github.com/jamiebuilds/86d467ee4353cb316edce8e69ad19237?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): strong and original opinions of Jamie Kyle about file-system routing conventions 🤔
-   📖 [Partytown + Hydrogen](https://partytown.builder.io/shopify-hydrogen?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): new integration doc
-   🐦 [Remix: animated page transitions with useOutlet()](https://twitter.com/buildsghost/status/1492201302423605252?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Outlet is a nice solution to avoid layout unmounts/remounts, making it much easier to implement page transitions
-   🎥 [Remotion Update - February 2022](https://www.youtube.com/watch?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter&v=fF_ABGkrKmg)
-   📜 [Hydrogen & Tailwind: The Perfect Match](https://shopify.engineering/hydrogen-tailwind-building-beautiful-storefronts?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): from Shopify, a bit of React, mostly Tailwind
-   📜 [Svelte vs. React in 2022: Choosing the Best Match for You](https://prismic.io/blog/compare-svelte-vs-react-2022?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

## 💸 Sponsors

[React Bricks: CMS with visual editing for Next.js, Gatsby and Remix, based on React components](https://reactbricks.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

**Content creators don't like the grey forms of a headless CMS.**

Visual tools like Wix or Webflow are either not flexible, complex to use or too flexible: a content creator should not decide on a margin, right?

React Bricks has the best of the 2 worlds: **all the advantages of a Headless CMS and best in class Visual editing experience** with no way to break the design system.

You create **visually editable content blocks as React components** using the react-bricks library. Content creators use these blocks to compose content with all the freedom they want and no more than they need.

Learn it in about 2 hours with the [Step-by-step tutorial](https://reactbricks.com/learn?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) or the full [Documentation](https://docs.reactbricks.com/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter).

[**Create your free account**](https://reactbricks.com/sign-up?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) and start building now!

## React-Native

[**Measuring and improving performance on a React Native app**](https://blog.bam.tech/developer-news/measuring-and-improving-performance-on-a-react-native-app?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

Alexandre presents his Flipper plugin to measure React-Native performances (UI & JS thread FPS) continuously and compute a score like Lighthouse.

He also shares 4 tips to help you measure performances on your apps. TIL about automating scroll with `adb`. All this is then applied in practice to a concrete use-case: his team improved the score of the TF1 app from 40 to 90.

**Extras:**

-   📜 [4 years as a React Native OSS maintainer: a retrospective](https://gist.github.com/kelset/05ae2f4a861c2252fc592ebadd7e0f25?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): being a maintainer is not always easy 😅
-   📜 [Calling Windows APIs from React Native just got easier](https://microsoft.github.io/react-native-windows/blog/2022/02/11/rnwinrt?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Microsoft introduces a new React-Native package to call any WinRT API directly from JS in a very flexible way, without any additional boilerplate. Note that a similar initiative exists for iOS ([react-native-native-runtime](https://github.com/shirakaba/react-native-native-runtime?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)) but not sure Apple would approve 😝
-   📜 [React Native for Windows is helping Settings improve more quickly](https://microsoft.github.io/react-native-windows/blog/2022/02/11/settings?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): Microsoft's feedback on a concrete cross-platform use-case where they share code between desktop (using the WinRT package above) and web
-   🎥 [Orta Dev Diary 2 - React Native Web](https://www.youtube.com/watch?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter&v=2NItowAgfNA)
-   🎙️ [RNR 226 - GraphQL in React Native](https://reactnativeradio.com/episodes/rnr-226-graphql-in-react-native?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

## 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

[**Hello, CSS Cascade Layers**](https://ishadeed.com/article/cascade-layers/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

A nice intro to CSS Cascade layers, a new CSS feature to look forward! It looks like it [is coming fast](https://twitter.com/stefanjudis/status/1492655597459808258?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) in our browsers, and even if you can't use it today (no polyfill), that's worth taking a look at it today.

CSS Cascade Laters give additional control on the CSS cascade, and the order in which CSS rules are applied. This can help fixing problems related to specificity, insertion order or reduce the need to use `!important`.

If you only have 1 minute, [take a look at this animation](https://twitter.com/bramus/status/1493330153681920001?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter). It's like if the browser re-ordered your styles instead of using the order defined in the CSS file. This also [reminds me a bit hooks React](https://twitter.com/threepointone/status/1056594421079261185?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) 😅.

Why does it matter? Because bundlers and frontend tools don't have any clear rule to emit the bundled CSS in a correct predictible order. For example, with Webpack, CSS loaders, JS/CSS code-splitting, dynamic imports, CJS/ESM, do you really know in which order your CSS rules will be in the final page? Definitively not me! 🤷‍♂️

With this new feature, your CSS may become more portable. If you decide to use another bundler/tool someday, you don't want to have to rewrite everything and fix a ton of little CSS issues related to changes in the CSS insertion order: layers can prevent that.

There's a lot of activity on the CSS side these days. Also take a look at the [Interop 2022](https://www.bram.us/2022/02/13/interop-2022/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) project: features that browsers plan to focus on this year regarding browser compatibility, including cascade layers!

**Extras:**

-   [Announcing TypeScript 4.6 RC](https://devblogs.microsoft.com/typescript/announcing-typescript-4-6-rc/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): great [improvements on Control Flow Analysis](https://twitter.com/sebastienlorber/status/1488096041299816453?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter), very nice for React
-   [Typescript - (ReadOnly) NotEmptyArray](https://dev.to/this-is-learning/typescript-readonlynotemptyarray-2id7?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): useful tuple technique to know: `[T, ...T[]];`
-   [Assertion Functions in TypeScript](https://mariusschulz.com/blog/assertion-functions-in-typescript?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): useful feature for type-narrowing
-   [*"Extract in TS can be used to query a member of a union type."*](https://twitter.com/farzad_yz/status/1492127144423694338?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [SWC v1.2.139](https://twitter.com/swc_rs/status/1492454606118752257?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): introduce new Rust plugin system
-   [Why I prefer JS for front-end build automation](https://thoughtspile.github.io/2022/02/14/js-automation/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): for sure it's better than bash 😅
-   [npm RFC: Package Distributions](https://github.com/npm/rfcs/pull/519?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): suggest new solutin for lib authors that need to distribute platform-specific binaries. Looks useful for modern tooling in Rust, Go...
-   [Node.js 17.5.0](https://twitter.com/ruyadorno/status/1491847226662043649?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): fetch (behind flag), JSON modules
-   [Jest v28.0 alpha](https://twitter.com/thymikee/status/1492065154258935823?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): ligher, remove deps JSDOM, Jasmine
-   [AbortController -> TaskController](https://twitter.com/sebmarkbage/status/1492142346867286018?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): assign priority to JS tasks?
-   [Parcel 2.3](https://twitter.com/parceljs/status/1491465162456502274?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) + [Parcel CSS 1.3](https://twitter.com/devongovett/status/1493256831879237632?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) + [Webpack integration example](https://twitter.com/devongovett/status/1491818780418318336?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [EdgeDB 1.0](https://www.edgedb.com/blog/edgedb-1-0?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter) with a [query builder TypeScript](https://twitter.com/edgedatabase/status/1491534099042897923?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Rome Formatter and Rust Update](https://rome.tools/blog/2022/02/08/rome-formatter-and-rust-update?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): initial focus seems to be on a code formatter that will try to [sync with Prettier](https://twitter.com/Vjeux/status/1491180045905567744?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter).
-   [Flutter in 2022: strategy and roadmap](https://medium.com/flutter/flutter-in-2022-strategy-and-roadmap-8c5eaf7c4275?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter): improvements planned on web support
-   [Vite 2.8](https://twitter.com/vite_js/status/1491407504336879617?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [ESLint 8.9](https://eslint.org/blog/2022/02/eslint-v8.9.0-released?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Is Turborepo overhyped?](https://tolgee.io/blog/turborepo-overhyped?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Move over JavaScript: Back-end languages are coming to the front-end](https://github.com/readme/featured/server-side-languages-for-front-end?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Storybook: Component Encyclopedia beta](https://storybook.js.org/blog/component-encyclopedia-beta/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Static Files on Deno Deploy](https://deno.com/blog/deploy-static-files?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Debugging JavaScript](https://flaviocopes.com/debugging/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Inside the JavaScript Engine](https://blog.devgenius.io/inside-the-javascript-engine-bb7b9f26e84b?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Design system versioning: single library or individual components?](https://bradfrost.com/blog/post/design-system-versioning-single-library-or-individual-components/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [How not to learn GraphQL](https://www.the-guild.dev/blog/how-not-to-learn-graphql?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Implementing A Svelte Store In Rust](https://daveceddia.com/svelte-store-in-rust/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [The first developer preview of Android 13](https://android-developers.googleblog.com/2022/02/first-preview-android-13.html?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)
-   [Server-Sent Events: the alternative to WebSockets you should be using](https://germano.dev/sse-websockets/?utm_campaign=thisweekinreact&utm_medium=email&utm_source=Revue%20newsletter)

 <img width="687" alt="image" src="https://user-images.githubusercontent.com/749374/154238081-5c551369-bdd1-4516-ab63-b7b2599377e7.png">