so I'm new at react and I have this problem when I want to disable Button when input is empty in react it only works one time until ;(
import React, { Component } from 'react';
class Form extends Component {
render() {
// start disable button when input is empty
const success = () => {
if (document.getElementById("id").value === "") {
document.getElementById('button').disabled = true;
} else {
document.getElementById('button').disabled = false;
}
}
// End disable button when input is empty
return (
<form onSubmit={this.props.addCourse}>
<input onKeyUp={() => success()} id='id' value={this.props.value} type='text' onChange={this.props.updateCourse} />
<button disabled id="button" type='submit'>Add Course</button>
</form>
);
};
}
export default Form;