Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Last active August 29, 2015 14:21
Show Gist options
  • Save Sigmus/f8afc38251cd4b9a90a7 to your computer and use it in GitHub Desktop.
Save Sigmus/f8afc38251cd4b9a90a7 to your computer and use it in GitHub Desktop.

Revisions

  1. Sigmus revised this gist May 13, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion focus-first-ref.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ module.exports = {
    },

    focusFirstInput() {
    const input = this.refs.firstInput;
    const input = this.refs.firstInput; // <input ref="firstInput" />
    if (input) {
    React.findDOMNode(input).focus();
    }
  2. Sigmus created this gist May 13, 2015.
    16 changes: 16 additions & 0 deletions focus-first-ref.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    const React = require('react');

    module.exports = {

    componentDidMount() {
    this.focusFirstInput();
    },

    focusFirstInput() {
    const input = this.refs.firstInput;
    if (input) {
    React.findDOMNode(input).focus();
    }
    }

    };