How to use the react.createRef function in react

To help you get started, weโ€™ve selected a few react 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 kyma-project / console / compass / src / components / Application / ApplicationDetails / CreateAPIModal / CreateAPIModal.component.js View on Github external
import './style.scss';

import {
  createAPIDefinition,
  createEventDefinition,
} from './../../../Api/APICreationHelper';

import APIDataForm from './../../../Api/Forms/ApiDataForm';
import CredentialsForm, {
  CREDENTIAL_TYPE_PLACEHOLDER,
} from '../../../Api/Forms/CredentialForms/CredentialsForm';

export default class CreateAPIModal extends React.Component {
  state = this.createInitialState();
  formRef = React.createRef();

  createInitialState() {
    return {
      isReadyToUpload: false,

      apiData: {
        name: '',
        description: '',
        group: '',
        targetURL: '',

        spec: null,
        actualFileType: null,
        loadedFileContent: null,
        mainAPIType: null /* API, EVENT_API, UNKNOWN */,
        apiSubType: null /* ASYNC_API, OPEN_API, ODATA */,
github Caldis / react-zmage / src / Zmage.js View on Github external
constructor(props){
        super(props)

        this.coverRef = React.createRef()
        this.isBrowsingControlled = this.props.hasOwnProperty('browsing')

        this.state = {
            // ๆต่งˆ
            browsing: false,
        }

        // TODO:FEATURE ๆŒ‰้’ฎ้ขœ่‰ฒ้…็ฝฎ
        // TODO:FEATURE ็งปๅŠจ็ซฏ็š„ๆ‹–ๆ‹ฝ็ฟป้กต
        // TODO:ENHANCE ็ฆ็”จ็งปๅŠจ็ซฏ็š„ๆป‘ๅŠจ้€€ๅ‡บ
        // TODO:BUG     ็งปๅŠจ็ซฏไธ‹ๅทฆๅณๆŒ‰้’ฎ
    }
github l3p-cv / lost / frontend / lost / src / components / SIA / Canvas.js View on Github external
// selectedAnnoId: {id:undefined},
            selectedAnnoId: undefined,
            showSingleAnno: undefined,
            showLabelInput: false,
            imageLoaded: false,
            imgLabelIds: [],
            imgLabelChanged: false,
            performedImageInit: false,
            prevLabel: [],
            imageData: undefined,
            isJunk: false,
            imgBarVisible:false,
            annoToolBarVisible: false
        }
        this.img = React.createRef()
        this.svg = React.createRef()
        this.container = React.createRef()
        this.hist = new UndoRedo()
        this.keyMapper = new KeyMapper((keyAction) => this.handleKeyAction(keyAction))
        this.mousePos = undefined
    }
github Vizzuality / trase / frontend / scripts / react-components / nav / top-nav-redesign / top-nav-redesign.component.jsx View on Github external
const DownloadPdfLink = React.lazy(() => import('./download-pdf-link.component'));

class TopNavRedesign extends React.PureComponent {
  state = {
    backgroundVisible: false,
    menuOpen: false
  };

  navLinkProps = {
    exact: false,
    strict: false,
    isActive: null
  };

  mobileMenuRef = React.createRef(null);

  componentDidMount() {
    // window.addEventListener('click', this.handleClickOutside);
    window.addEventListener('scroll', this.setBackground, { passive: true });
  }

  componentDidUpdate(prevProps) {
    if (prevProps.page !== this.props.page && this.state.menuOpen) {
      this.handleToggleClick();
    }
  }

  componentWillUnmount() {
    this.setBackground.cancel();
    window.removeEventListener('click', this.handleClickOutside);
    window.removeEventListener('scroll', this.setBackground);
github MetaMask / metamask-mobile / app / components / Views / Wallet / index.js View on Github external
collectibles: PropTypes.array,
		/**
		 * Current provider ticker
		 */
		ticker: PropTypes.string,
		/**
		 * Current onboarding wizard step
		 */
		wizardStep: PropTypes.number
	};

	state = {
		refreshing: false
	};

	accountOverviewRef = React.createRef();

	mounted = false;

	async init() {
		const { AssetsDetectionController, AccountTrackerController } = Engine.context;
		AssetsDetectionController.detectAssets();
		AccountTrackerController.refresh();
		this.mounted = true;
	}

	componentDidMount() {
		requestAnimationFrame(() => {
			this.init();
		});
	}
github ra-gg / Delir / packages / delir / views / KeyframeEditor / _DelirValueInput.tsx View on Github external
descriptor: Delir.AnyParameterTypeDescriptor
    value: Delir.Entity.KeyframeValueTypes
    onChange: (desc: Delir.AnyParameterTypeDescriptor, value: Delir.Entity.KeyframeValueTypes) => void
}

export default class DelirValueInput extends React.PureComponent {
    public state = {
        value: this.props.value,
    }
    private ref = {
        numberInput: React.createRef(),
        propX: React.createRef(),
        propY: React.createRef(),
        propZ: React.createRef(),
        propWidth: React.createRef(),
        propHeight: React.createRef(),
        propDepth: React.createRef(),
        colorPicker: React.createRef(),
        checkbox: React.createRef(),
        textArea: React.createRef(),
        enumSelect: React.createRef(),
        assetSelect: React.createRef(),

        textSummary: React.createRef(),
        textInputDropdown: React.createRef(),

        colorPickerDropdown: React.createRef(),
    }

    public componentWillReceiveProps(nextProps: Readonly, nextContext: any) {
        if (this.props.value !== nextProps.value) {
            setTimeout(() => this.setState({ value: nextProps.value }), 0)
github flapjs / FLAPJS-WebApp / src / services / graph / components / widgets / formatter / DebounceInput.jsx View on Github external
constructor(props)
    {
        super(props);

        this._inputElement = React.createRef();

        this._debounceTimeout = null;
        this._ignoreNextBlurEvent = false;

        this._prevCaretPosition = { start: -1, end: -1 };

        this.onFocus = this.onFocus.bind(this);
        this.onBlur = this.onBlur.bind(this);
    }
github all-of-us / workbench / ui / src / app / pages / data / cohort-review / participants-charts.tsx View on Github external
const data = resp.items.map(item => {
            this.nameRefs.push(React.createRef());
            const percentCount = Math.round((item.count / resp.count) * 100);
            return {...item, percentCount};
          });
          this.setState({data, loading: false});
github elasticpath / react-pwa-reference-storefront / components / src / BarcodeScanner / barcodescanner.tsx View on Github external
constructor(props) {
    super(props);
    this.state = {
      barcodes: [],
    };
    const epConfig = getConfig();
    ({ intl } = epConfig);
    this.onDetected = this.onDetected.bind(this);
    this.onModalClose = this.onModalClose.bind(this);
    this.initScanner = this.initScanner.bind(this);
    this.stopScanning = this.stopScanning.bind(this);
    this.scannerContainer = React.createRef();
  }
github davidbalbert / spreadsheet.js / src / FormulaEditor.js View on Github external
import React, { Component } from 'react';
import './FormulaEditor.scss'

class FormulaEditor extends Component {
  inputRef = React.createRef();

  handleInputChange = (e) => {
    const {onChange} = this.props;

    onChange(e.target.value);
  }

  handleKeyDown = (e) => {
    const {onKeyDown} = this.props;

    onKeyDown(e);
  }

  focus() {
    this.inputRef.current.focus()
  }