Answer the question
In order to leave comments, you need to log in
React currency converter. Where to implement the recalculation function?
I am making a currency converter. There are 2 inputs. When you enter a number in the first input, the result should automatically be displayed in the second input and vice versa, if you enter in the second, the result is displayed in the first.
I made the display of the input number in the input and display it in the second input, but where can I implement the recalculation of the input number?
class Form extends React.Component{
state={
firstValue:'',
secondValue:'',
}
handleChange =(event)=>{
this.setState({firstValue:event.target.value,secondValue: event.target.value},
);
}
render() {
const {firstValue, secondValue}= this.state;
console.log(firstValue)
return<div>
<input type="number" name='firstValue' value={this.state.secondValue} onChange={this.handleChange}/>
<input type="number" name='secondValue' value={this.state.firstValue} onChange={this.handleChange}/>
</div>
}
}
export default Form;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question