React vs JS
Posted on October 2, 2021
Tags: javascript
Build a textbox that reactively logs the current value of the textbox as you input
<input style="margin:10" type="text" maxLength=3 name="box1"/>
<input style="margin:10" type="text" maxLength=3 name="box2"/>
<script>
let box1 = document.querySelector("input[name=box1]");
let box2 = document.querySelector("input[name=box2]");
.addEventListener("input",(e) => {
box1console.log(e.target.value);
;
})</script>
const [getVal_box1,setVal_box1] = useState("")
<Input
={(e)=>{
onChangesetVal_box1((old)=>e.target.value);
console.log(getVal_box1());
}}/>