Why can't I change my input value in React even with the onChange listener

前端 未结 6 1197
再見小時候
再見小時候 2021-02-05 00:20

I am quite new to React and after going through some tutorials, I was trying the below code of mine.

I made one component, passed props to it from a store, on compo

6条回答
  •  走了就别回头了
    2021-02-05 00:39

    I think it is best way for you.

    You should add this: this.onTodoChange = this.onTodoChange.bind(this).

    And your function has event param(e), and get value:

    componentWillMount(){
            this.setState({
                updatable : false,
                name : this.props.name,
                status : this.props.status
            });
        this.onTodoChange = this.onTodoChange.bind(this)
        }
        
        
    
    
    onTodoChange(e){
             const {name, value} = e.target;
            this.setState({[name]: value});
       
    }
    

提交回复
热议问题