What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-08 02:45:03
innerWidth react
const [width, setWidth] = useState(window.innerWidth); const [height, setHeight] = useState(window.innerHeight); const updateDimensions = () => { setWidth(window.innerWidth); setHeight(window.innerHeight); } useEffect(() => { window.ad... Add solution -
Javascript 2021-10-06 08:26:03
react get dynamic window sizes
import { useState, useEffect } from 'react'; function getWindowDimensions() { const { innerWidth: width, innerHeight: height } = window; return { width, height }; } export default function useWindowDimensions() { const [windowDimensions,... Add solution -
Javascript 2021-10-06 04:34:06
passing event handler to useEffeect
const App =() => { const [userText, setUserText] = useState(""); useEffect(() => { const handleUserKeyPress = event => { const { key, keyCode } = event; if (keyCode === 32 || (keyCode >= 65 && keyCode &l... Add solution -
Javascript 2021-10-03 19:08:02
mozilla observer onclick
var observeDOM = (function(){ var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; return function( obj, callback ){ if( !obj || obj.nodeType !== 1 ) return; if( MutationObserver ){ // define a new observer... Add solution -
Javascript 2021-10-03 14:23:03
detect when scrolling stops
// Setup isScrolling variable var isScrolling; // Listen for scroll events window.addEventListener('scroll', function ( event ) { // Clear our timeout throughout the scroll window.clearTimeout( isScrolling ); // Set a timeout to run after scrolling ... Add solution
Best helpers
Ranking is empty