Skip to content

Instantly share code, notes, and snippets.

View Felix-Indoing's full-sized avatar

Felix-Indoing

View GitHub Profile
@Felix-Indoing
Felix-Indoing / use100vh.js
Created August 7, 2020 12:47 — forked from franky47/use100vh.js
React hook to fix the 100vh issue on mobile Chrome and Safari
import React from 'react';
import { useWindowSize } from 'react-use';
// 100vh is broken on mobile (Chrome, Safari):
// https://chanind.github.io/javascript/2019/09/28/avoid-100vh-on-mobile-web.html
export default function use100vh() {
const ref = React.useRef();
const { height } = useWindowSize();