How to use the @wordpress/element.createRef function in @wordpress/element

To help you get started, we’ve selected a few @wordpress/element 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 WordPress / gutenberg / packages / components / src / drop-zone / index.js View on Github external
constructor() {
		super( ...arguments );

		this.dropZoneElement = createRef();
		this.dropZone = {
			element: null,
			onDrop: this.props.onDrop,
			onFilesDrop: this.props.onFilesDrop,
			onHTMLDrop: this.props.onHTMLDrop,
			setState: this.setState.bind( this ),
		};
		this.state = {
			isDraggingOverDocument: false,
			isDraggingOverElement: false,
			position: null,
			type: null,
		};
	}
github WordPress / gutenberg / packages / editor / src / components / post-publish-panel / postpublish.js View on Github external
constructor() {
		super( ...arguments );
		this.state = {
			showCopyConfirmation: false,
		};
		this.onCopy = this.onCopy.bind( this );
		this.onSelectInput = this.onSelectInput.bind( this );
		this.postLink = createRef();
	}
github WordPress / gutenberg / packages / format-library / src / link / inline.js View on Github external
constructor() {
		super( ...arguments );

		this.editLink = this.editLink.bind( this );
		this.submitLink = this.submitLink.bind( this );
		this.onKeyDown = this.onKeyDown.bind( this );
		this.onChangeInputValue = this.onChangeInputValue.bind( this );
		this.setLinkTarget = this.setLinkTarget.bind( this );
		this.onClickOutside = this.onClickOutside.bind( this );
		this.resetState = this.resetState.bind( this );
		this.autocompleteRef = createRef();

		this.state = {
			opensInNewWindow: false,
			inputValue: '',
		};
	}
github Automattic / jetpack / extensions / blocks / map / location-search / index.js View on Github external
constructor() {
		super( ...arguments );

		this.textRef = createRef();
		this.containerRef = createRef();
		this.state = {
			isEmpty: true,
		};
		this.autocompleter = {
			name: 'placeSearch',
			options: this.search,
			isDebounced: true,
			getOptionLabel: option =&gt; <span>{ option.place_name }</span>,
			getOptionKeywords: option =&gt; [ option.place_name ],
			getOptionCompletion: this.getOptionCompletion,
		};
	}
	componentDidMount() {
github WordPress / gutenberg / packages / components / src / sandbox / index.js View on Github external
constructor() {
		super( ...arguments );

		this.trySandbox = this.trySandbox.bind( this );
		this.checkMessageForResize = this.checkMessageForResize.bind( this );

		this.iframe = createRef();

		this.state = {
			width: 0,
			height: 0,
		};
	}
github Automattic / vip-go-mu-plugins-built / jetpack / extensions / blocks / slideshow / slideshow.js View on Github external
constructor( props ) {
		super( props );

		this.slideshowRef = createRef();
		this.btnNextRef = createRef();
		this.btnPrevRef = createRef();
		this.paginationRef = createRef();
	}
github Automattic / newspack-plugin / assets / components / src / text-control / index.js View on Github external
constructor( props ) {
		super( props );
		this.wrapperRef = createRef();
	}
	componentDidMount() {
github dsifford / academic-bloggers-toolkit / src / js / components / textarea-autosize / index.tsx View on Github external
function TextareaAutosize({ inputRef, className, ...props }: Props) {
    const ref = inputRef || createRef();

    useEffect(() =&gt; {
        const { current: textarea } = ref;
        if (textarea) {
            const offset = textarea.offsetHeight - textarea.clientHeight;
            textarea.style.height = 'auto';
            textarea.style.height = `${textarea.scrollHeight + offset}px`;
        }
    });

    return (
github google / site-kit-wp / assets / js / components / user-menu.js View on Github external
constructor( props ) {
		super( props );

		this.state = {
			dialogActive: false,
			menuOpen: false,
		};

		this.handleMenu = this.handleMenu.bind( this );
		this.handleMenuClose = this.handleMenuClose.bind( this );
		this.handleMenuItemSelect = this.handleMenuItemSelect.bind( this );
		this.handleDialog = this.handleDialog.bind( this );
		this.handleDialogClose = this.handleDialogClose.bind( this );
		this.handleUnlinkConfirm = this.handleUnlinkConfirm.bind( this );

		this.menuButtonRef = createRef();
		this.menuRef = createRef();
	}