Skip to content

Instantly share code, notes, and snippets.

View renet's full-sized avatar

René Schubert renet

View GitHub Profile
@jsdf
jsdf / setupTestFramework.js
Created November 5, 2015 09:27
Make React PropType warnings throw errors in Jasmine/Jest
var util = require('util');
// nobody cares about warnings so lets make them errors
// keep a reference to the original console methods
var consoleWarn = console.warn;
var consoleError = console.error;
function logToError() {
throw new Error(util.format.apply(this, arguments).replace(/^Error: (?:Warning: )?/, ''));
@blech75
blech75 / withAmpSass.js
Created August 16, 2018 14:42
next.js webpack config for outputting AMP-specific Sass to separate file
// Copied from @zeit/next-sass and modified to so that we can define AMP styles
// in *.amp.scss and normal styles in *.scss (excludes *.amp.scss). Normal
// styles are output as before; AMP styles are output to styles-amp.scss
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssLoaderConfig = require('@zeit/next-css/css-loader-config');
const commonsChunkConfig = require('@zeit/next-css/commons-chunk-config');
module.exports = (nextConfig = {}) =>
Object.assign({}, nextConfig, {
@gaearon
gaearon / uselayouteffect-ssr.md
Last active March 17, 2025 10:13
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() {