Reactstrap: can't ref in <Input></Input>

Created on 5 May 2018  路  3Comments  路  Source: reactstrap/reactstrap

Issue description

  • components: Input
  • reactstrap version #6.0.1
  • import method umd/csj/es
  • react version #16.3.2
  • bootstrap version #4.1.1

What is happening?


I just put ref on Input tag but, I can't I use typescript, so I used any type, but doesn't work

What should be happening?

can use ref in

Steps to reproduce issue

  1. ... Declare variables ex) public password: any = null
  2. ... link ref in
  3. ... do it! this.password.focus()
  4. ... Error!

Error message in console

TypeError: _this.password.focus is not a function

Code

class Login extends React.Component {
public password: any = null

someMethod = () => {
     this.password.focus()
}

render() {
    return (
                <Input
                  type="password"
                  placeholder="Password Here"
                  ref={ref => {
                    this.password = ref
                  }}
                />
                <button onClick={this.someMethod}> Click me! </button>
      )
   }
}

Most helpful comment

ref can only get a reference to the thing you use it on, Input. Use innerRef to get a reference to the underlying input.

All 3 comments

ref can only get a reference to the thing you use it on, Input. Use innerRef to get a reference to the underlying input.

Thank You!

ref can only get a reference to the thing you use it on, Input. Use innerRef to get a reference to the underlying input.

Thanks man,you save my day

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gthomas-appfolio picture gthomas-appfolio  路  3Comments

paulevmo picture paulevmo  路  3Comments

nitingupta910 picture nitingupta910  路  3Comments

dhwrwmgwra picture dhwrwmgwra  路  3Comments

agos picture agos  路  3Comments