componentWillMount() { const onResize = () => { const breakpoint = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content').replace(/"/g, ''); this.props.updateStyleBreakpoint(breakpoint); }; window.addEventListener('resize', throttle(onResize, 150)); onResize(); }
constructor(props) { super(props); this.listener = throttle(this.scrollListener, 200).bind(this); }
const useThrottledFn = ( fn, wait = 100, options = { leading: false, trailing: true, }, dependencies, ) => { const throttled = throttle(fn, wait, options); return useCallback(throttled, dependencies); }
const configureStore = () => { const persistedState = loadState() || games; const store = createStore( gamesApp, persistedState ); store.subscribe(throttle(() => { saveState({ games: store.getState().games }); }, 1000)); return store; }
constructor(props) { super(props) this.refsDic = { footer: React.createRef() } for (let el of props.subQuests) { this.refsDic[el.id] = React.createRef() } this.refsArray = props.subQuests .map(quest => this.refsDic[quest.id]) .concat(this.refsDic.footer) this.onScrollThrottled = throttle(this.onScroll, 100) this.state = { focusedId: '', activeUp: false, activeDown: true } }
throttle((progress) => { this.setState({ progress }) }, 200)