Convert name field into controlled component

This commit is contained in:
Alex Liebowitz 2016-11-18 03:49:16 -05:00
parent 6ac9853fd4
commit aea1c7e6ee

View file

@ -111,6 +111,7 @@ var PublishPage = React.createClass({
this._tempFilePath = null;
return {
rawName: '',
name: '',
bid: '',
feeAmount: '',
@ -152,6 +153,7 @@ var PublishPage = React.createClass({
if (!rawName) {
this.setState({
rawName: '',
name: '',
nameResolved: false,
});
@ -159,6 +161,10 @@ var PublishPage = React.createClass({
return;
}
this.setState({
rawName: rawName,
});
var name = lbry.formatName(rawName);
lbry.resolveName(name, (info) => {
@ -340,7 +346,7 @@ var PublishPage = React.createClass({
<section className="card">
<h4>LBRY Name</h4>
<div className="form-row">
lbry://<FormField type="text" ref="name" onChange={this.handleNameChange} />
lbry://<FormField type="text" ref="name" value={this.state.rawName} onChange={this.handleNameChange} />
{
(!this.state.name ? '' :
(! this.state.nameResolved ? <em> The name <strong>{this.state.name}</strong> is available.</em>