Skip to content

Instantly share code, notes, and snippets.

View likesalmon's full-sized avatar

Ammon Morris likesalmon

View GitHub Profile
@ivanbtrujillo
ivanbtrujillo / react-lazy-with-reload.ts
Created November 30, 2023 11:15
react-lazy-with-reload.ts
/**
* This is a wrap for React.Lazy based on Christoph Nakazawa solution (https://gist.github.com/cpojer/c50a742ec943d95c3c72a41ac1c06f03) for the issue that happens when using React.Lazy and we deploy a new version of a module, changing the hash (automatically managed by bundlers).
*
* THE PROBLEM:
* When our React application is compiled for production, packaging tools (Vite in this case) often add hashes to the filename to handle caching.
* These hashes change whenever the content of the file changes. This ensures that users get the most recent version of the file, since a change in the hash will force the browser to download the new file instead of serving a cached version.
*
* If a user has your application open and you make a new deployment, the file names of the dynamically loaded modules may change (due to the new hashes).
* And then, if the user navigates to a part of your application that requires loading a new module, their browser will attempt to load the module using the old file name (which i
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing