How to use the preact.options.debounceRendering function in preact

To help you get started, we’ve selected a few preact examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github developit / preact-redux / test / provider.js View on Github external
import { createStore } from 'redux';
import { Provider, connect, connectAdvanced } from '../';
import { render, options } from 'preact';
import React from 'preact';

import * as Redux from '../dist/preact-redux.esm.js';

// disable async rendering entirely to make tests simpler
options.debounceRendering = f => f();

describe('preact-redux', () => {
	it('should export Provider & connect', () => {
		expect(Provider).to.be.a('function');
		expect(connect).to.be.a('function');
	});

	describe('', () => {
		it('should commit store prop to context', () => {
			let store = createStore( a => a );
			let Child = sinon.stub().returns(<div>);

			render((
				
					
				</div>
github bvaughn / tweets / src / pages / Timeline / index.js View on Github external
import { h, Component, options } from 'preact';
import LoadingIndicator from 'components/LoadingIndicator';
import TweetList from 'components/TweetList';
import TweetStream from './TweetStream';
import config from '../../config';

// Use requestAnimationFrame by default but allow URL param to disable.
options.debounceRendering = location.search.indexOf('raf=false') &lt; 0
  ? requestAnimationFrame
  : null;

export default class Timeline extends Component {
  state = {
    tweets: [],
  };

  componentDidMount() {
    this._tweetStream = new TweetStream();
    this._fetchTweets();
  }

  render() {
    const { authenticated, disableMedia, tweets } = this.state;
github prateekbh / preact-async-route / tests / index.js View on Github external
describe('Async Route', () =&gt; {
	options.syncComponentUpdates = false;
	options.debounceRendering = f =&gt; f();
	class SampleTag extends Component {
		render(){
			return (<h1>hi</h1>);
		}
	}
	class ParameterizedSampleTag extends Component {
		render(){
			return (<h1>hi - {this.props.matches.pid}</h1>);
		}
	}

	it('should call the given function on mount', () =&gt; {
		let getComponent = sinon.spy();
		render(, document.createElement('div'));
		expect(getComponent).called;
	});
github valotas / preact-context / src / _tests / context.Spec.tsx View on Github external
beforeEach(() =&gt; {
    options.debounceRendering = r =&gt; r();
    render();
  });
github preactjs / preact / test-utils / src / index.js View on Github external
export function setupRerender() {
	options.__test__previousDebounce = options.debounceRendering;
	options.debounceRendering = cb => (options.__test__drainQueue = cb);
	return () => options.__test__drainQueue && options.__test__drainQueue();
}
github preactjs / preact / test-utils / src / setupRerender.js View on Github external
export function setupRerender() {
	Component.__test__previousDebounce = options.debounceRendering;
	options.debounceRendering = cb => Component.__test__drainQueue = cb;
	return () => Component.__test__drainQueue && Component.__test__drainQueue();
}
github preactjs / preact / test-utils / src / setupRerender.js View on Github external
export function setupRerender() {
	Component.__test__previousDebounce = options.debounceRendering;
	options.debounceRendering = cb => Component.__test__drainQueue = cb;
	return () => Component.__test__drainQueue && Component.__test__drainQueue();
}
github preactjs / enzyme-adapter-preact-pure / src / debounce-render-hook.ts View on Github external
export function installHook() {
  if (hookInstalled) {
    return;
  }

  const origDebounce = options.debounceRendering || defer;
  function trackPendingRender(callback: () => any) {
    pendingCallbacks.add(callback);
    origDebounce.call(null, callback);
  }
  options.debounceRendering = trackPendingRender;
  hookInstalled = true;
}
github preactjs / enzyme-adapter-preact-pure / src / debounce-render-hook.ts View on Github external
export function installHook() {
  if (hookInstalled) {
    return;
  }

  const origDebounce = options.debounceRendering || defer;
  function trackPendingRender(callback: () => any) {
    pendingCallbacks.add(callback);
    origDebounce.call(null, callback);
  }
  options.debounceRendering = trackPendingRender;
  hookInstalled = true;
}
github malbernaz / preact-hn / src / client.js View on Github external
import { render, options } from "preact";
import Router from "universal-router";

import { updateTitle } from "./lib/updateTag";
import history from "./lib/history";
import Provider from "./lib/ContextProvider";
import UseScroll from "./lib/useScroll";
import registerServiceWorker from "./sw-register";
import store from "./store";
import routes from "./routes";

let CURRENT_LOCATION = history.location;
let FIRST_RENDER = true;

options.debounceRendering = requestAnimationFrame;

const scroll = new UseScroll(CURRENT_LOCATION);

const routerMiddleware = {
  preMiddleware() {
    return scroll.storeScroll(history);
  },
  postMiddleware({ title }) {
    updateTitle(title);
    scroll.restoreScroll(history.location);
  }
};

function insertCss(...styles) {
  const removeCss = styles.map(x => x._insertCss());