[英]Atlassian React Components - TextField Not Accepted
I am trying to implement Atlassian React Components in my application. 我正在尝试在我的应用程序中实现Atlassian React Components 。
But TextField is not behaving like normal input text field. 但是TextField的行为不像普通的输入文本字段。
It is not forwarding value while submitting form, and giving warning in console 提交表单并在控制台中发出警告时没有转发价值
Warning: styled.input is changing an uncontrolled input of type text to be controlled.
警告:style.input正在更改要控制的文本类型的不受控制的输入。 Input elements should not switch from uncontrolled to controlled (or vice versa).
输入元素不应从不受控制切换为受控制(反之亦然)。 Decide between using a controlled or uncontrolled input element for the lifetime of the component.
确定在组件的使用寿命期间使用受控或不受控制的输入元素。
import React, { Component } from 'react';
import { login, resetPassword } from '../helpers/auth';
import TextField from '@atlaskit/field-text';
function setErrorMsg(error) {
return {
loginMessage: error
}
}
export default class Login extends Component {
state = { loginMessage: null }
handleSubmit = (e) => {
e.preventDefault()
login(this.email.value, this.pw.value)
.catch((error) => {
//catch errors
})
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<div className="form-group">
<label>Email</label>
//THIS TEXTFIELD IS MAKING ISSUE
<TextField autoFocus ref={(email) => this.email = email} placeholder="Email" label="" />
</div>
<div className="form-group">
<label>Password</label>
<input type="password" className="form-control" placeholder="Password" ref={(pw) => this.pw = pw} />
</div>
<button type="submit" className="btn btn-primary">Login</button>
</form>
)
}
}
I just faced this problem. 我只是面对这个问题。 To solve it you just need to add prop
value=""
to your <TextField>
为了解决这个问题,您只需要在您的
<TextField>
添加prop value=""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.