Skip to content

Instantly share code, notes, and snippets.

@GiacoCorsiglia
GiacoCorsiglia / local-storage.ts
Created May 23, 2024 04:48
Local Storage Helpers
const createSafeStorage = (storage: Storage): Storage => ({
clear() {
try {
storage.clear();
} catch (e) {
console.warn("Unable to access storage", e);
}
},
getItem(key: string): string | null {
@GiacoCorsiglia
GiacoCorsiglia / mathjax-in-react.md
Last active June 10, 2024 16:38
Using MathJax v3 in React

Using MathJax v3 in React

Any improvements or alternative approaches are welcome!

One alternative approach can be found in the CharlieMcVicker/mathjax-react library.

Loading MathJax

It may be possible to bundle MathJax with the rest of your JavaScript, which might have the nice consequence of allowing you to import it instead of using the global MathJax object. But I found it simpler to include the following at the bottom of my html file; this is the common way to load MathJax.