How to get password field value in reaction-ui file

I cannot access the value <TextField />, if I do not write <input type='password'/>, then it works fine, but for this I get TypeError, ' this.refs [this._getRef (...)]. getInputNode is not a function .

 dialogAction(tag,e){

  console.log(this.refs.password);
  console.log(this.refs.password.getValue());
  this.refs.dialog.dismiss();
}

render(){
let self = this;

let row = this.row,col = this.column;
let standardActions = [
  { text: 'Cancel',onTouchTap: this.dialogAction.bind(this,ProductConstants.CANCEL)},
  { text: 'Submit',onTouchTap: this.dialogAction.bind(this,ProductConstants.SUBMIT)}
];

return (
  <div className="ProductRepository">

    <Dialog ref = 'dialog'
      title="Dialog With Standard Actions"
      actions={standardActions}
      actionFocus="submit"
      modal={true}>
      <TextField ref='password'
        hintText="Password"
        floatingLabelText="Password">
        <input type="password" />
      </TextField>
    </Dialog>
    </div> 
    );}

   }

The following is the console output above.

console output

+4
source share
4 answers

This solved my problem:

<TextField ref='password'
    hintText="Password"
    floatingLabelText="Password"
    type="password">
</TextField>

Thereafter

 this.refs.password.getValue()

gives the desired result.

For the reaction v> = 15.6

<TextField ref={x => this.password = x}
    hintText="Password"
    floatingLabelText="Password"
    type="password">
</TextField>

in the handler input function

this.password.value
+11
source

For material 1.0 and reaction 16.1.1

Use inputRef

  <TextField autoFocus={true} inputRef={el => this.fv = el} 
        placeholder="Required" size="30"></TextField >

To read the value used below the line

console.log(this.fv.value);
+5
source

ref="password" , TextField. getValue() (, ) (TextField), input.

, .

+1
source

You can get the input value as follows:

this.refs.password.input.value;
0
source

Source: https://habr.com/ru/post/1598158/


All Articles