ReactJs输入元素内容不变

ReactJs输入元素内容不变,reactjs,events,onchange,Reactjs,Events,Onchange,参考下面的代码,无论我在输入元素中键入什么,其值都不会更改。 似乎输入元素变成只读。 但是,onChange事件do fire和控制台日志输出始终显示初始值。 我的代码有什么问题吗 Combo.tsx import * as React from "react"; export interface ComboProps { label:string, value:string } // 'HelloProps' describes the shape of props. // State i

参考下面的代码,无论我在输入元素中键入什么,其值都不会更改。
似乎输入元素变成只读。 但是,onChange事件do fire和控制台日志输出始终显示初始值。 我的代码有什么问题吗

Combo.tsx

import * as React from "react";

export interface ComboProps { label:string, value:string }

// 'HelloProps' describes the shape of props.
// State is never set so we use the 'undefined' type.
export class Combo extends React.Component<ComboProps, ComboProps> {
    constructor(props:any){
        super(props);
        this.state = {label:this.props.label, value: this.props.value};
        this.update = this.update.bind(this);
    }
    update(event:any){
        console.log(this.state.value);
    }
    render() {
        return <div className="wo-boundary">
            <div  className="wo-label" ref="label">{this.state.label}</div>
            <div  className="wo-widget wo-input-module wo-combo">
                <input ref="box" type="text" onChange={this.update} value={this.state.value} />
                <div ref="toggle"  className="toggle">
                    <svg  className="icon-dropdown-toggle">
                        <use href="svg-symbols.svg#icon-dropdown-toggle"></use>
                    </svg>
                </div>
            </div>
        </div>;
    }
}
import*as React from“React”;
导出接口组合属性{label:string,value:string}
//“HelloProps”描述道具的形状。
//状态从未设置,因此我们使用“未定义”类型。
导出类组合扩展React.Component{
构造器(道具:任何){
超级(道具);
this.state={label:this.props.label,value:this.props.value};
this.update=this.update.bind(this);
}
更新(事件:任何){
console.log(this.state.value);
}
render(){
返回
{this.state.label}
;
}
}

您需要在
update
回调中更新状态:

update(event){
    this.setState({value: event.target.value});
}
我认为“任何”类型的注释真的带来了什么?