Skip to content

Instantly share code, notes, and snippets.

View jack-sf's full-sized avatar

Jack Tomaszewski jack-sf

View GitHub Profile
@gaearon
gaearon / uselayouteffect-ssr.md
Last active October 22, 2024 04:12
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() {
@donaldpipowitch
donaldpipowitch / axe.js
Created November 26, 2018 11:44
aXe based a11y checks in your CI for Storybook
const puppeteer = require('puppeteer');
const chalk = require('chalk');
const { green, red, cyan, grey, bold } = chalk;
// we assume storybook can visited at http://localhost:9001
const url = 'http://localhost:9001/iframe.html';
const runAxe = () =>
new Promise((resolve, reject) =>
@jbatchelor
jbatchelor / Native mobile select list triggering
Created March 15, 2013 14:25
Trigger native mobile select list with a button click.
Nifty trick for using a native mobile select list but triggering it with a button click:
Given:
<div class="box">
<i class="my-icon"/>
<select class="multi" multiple="true">
<option>1</option>
<option>2</option>
<option>3</option>
</select>