Skip to content

Instantly share code, notes, and snippets.

@miguelangeltorresfp
miguelangeltorresfp / uselayouteffect-ssr.md
Created November 9, 2020 04:34 — forked from gaearon/uselayouteffect-ssr.md
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@miguelangeltorresfp
miguelangeltorresfp / machine.js
Last active October 24, 2019 14:13
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@miguelangeltorresfp
miguelangeltorresfp / withStorage.js
Created June 18, 2019 00:28 — forked from treyhuffine/withStorage.js
A higher-order component to access localStorage
import React from 'react';
const withStorage = (WrappedComponent) => {
class HOC extends React.Component {
state = {
localStorageAvailable: false,
};
componentDidMount() {
this.checkLocalStorageExists();
@miguelangeltorresfp
miguelangeltorresfp / sublime-text-3-windows-shortcuts.md
Created October 11, 2018 18:30 — forked from mrliptontea/sublime-text-3-windows-shortcuts.md
Sublime Text 3 - Useful Shortcuts (Windows)

Sublime Text 3 - Useful Shortcuts (Windows)

General

Shortcut Description
Ctrl+Shift+P command prompt
Ctrl+Alt+P switch project
Ctrl+P go to file
Ctrl+G go to line