How to use the preact.createRef 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 Automattic / jetpack / modules / search / instant-search / components / search-app.jsx View on Github external
constructor() {
		super( ...arguments );
		this.input = createRef();
		this.requestId = 0;

		// TODO: Rework this line; we shouldn't reassign properties.
		this.props.aggregations = buildFilterAggregations( this.props.options.widgets );

		this.state = { isLoading: false, response: {}, showResults: false };
		this.getDebouncedResults = debounce( this.getResults, 200 );
		this.prepareDomForMounting();
	}
github Automattic / jetpack / modules / search / instant-search / components / search-filter.jsx View on Github external
constructor( props ) {
		super( props );
		this.filtersList = createRef();
		this.idPrefix = uniqueId( 'jetpack-instant-search__filter-' );

		if ( this.props.type === 'date' ) {
			// NOTE: This assumes that the configuration never changes. It will break if we
			// ever adjust it dynamically.
			this.dateOptions = getDateOptions( this.props.configuration.interval );
		}
	}
github testing-library / preact-testing-library / src / __tests__ / act.js View on Github external
test('findByTestId returns the element', async () => {
  const ref = createRef()

  const { findByTestId } = render(<div data-testid="foo">)

  expect(await findByTestId('foo')).toBe(ref.current)
})
</div>
github testing-library / preact-testing-library / src / __tests__ / render.js View on Github external
test('renders div into document', () =&gt; {
  const ref = createRef()

  const { container } = render(<div>)

  expect(container.firstChild).toBe(ref.current)
})
</div>
github select2 / select2 / control / src / single-select.tsx View on Github external
constructor(props) {
        super(props);

        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();
        this.valueRef = createRef();

        this.state = extend(this.state, { value: this.props.value });
    }
github select2 / select2 / control / src / single-select.tsx View on Github external
constructor(props) {
        super(props);

        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();
        this.valueRef = createRef();

        this.state = extend(this.state, { value: this.props.value });
    }
github select2 / select2 / control / src / multi-select.tsx View on Github external
constructor(props) {
        super(props);
        const { values } = props;

        this.valuesRef = createRef();
        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();

        this.state = extend(this.state, {
            values: {
                active: -1,
                selected: values.map(v => false)
            }
        });
    }
github select2 / select2 / control / src / multi-select.tsx View on Github external
constructor(props) {
        super(props);
        const { values } = props;

        this.valuesRef = createRef();
        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();

        this.state = extend(this.state, {
            values: {
                active: -1,
                selected: values.map(v => false)
            }
        });
    }
github select2 / select2 / control / src / multi-select.tsx View on Github external
constructor(props) {
        super(props);
        const { values } = props;

        this.valuesRef = createRef();
        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();

        this.state = extend(this.state, {
            values: {
                active: -1,
                selected: values.map(v => false)
            }
        });
    }
github select2 / select2 / control / src / single-select.tsx View on Github external
constructor(props) {
        super(props);

        this.searchRef = createRef();
        this.bodyRef = createRef();
        this.containerRef = createRef();
        this.dropdownRef = createRef();
        this.valueRef = createRef();

        this.state = extend(this.state, { value: this.props.value });
    }