diff --git a/equations/src/App.js b/equations/src/App.js index bf15fa4..c4bc1ae 100644 --- a/equations/src/App.js +++ b/equations/src/App.js @@ -7,16 +7,30 @@ function EquationGroup(p) { const [myArr,setMyArr] = useState(arr) + useEffect(()=>{ + var eqArr = [...equation] + eqArr[id] = [...myArr] + setEquation(eqArr) + },[myArr]) + return <> - ( + ( {arr.map((eq,i)=>Array.isArray(eq)?:eq==="×"||eq==="-"||eq==="+"||eq==="÷"?:)} - ) + ) } function EquationOperator(p) { const {equation,setEquation,data,operator,key,id} = p + const [op,setOp] = useState(operator) + + useEffect(()=>{ + var eqArr = [...equation] + eqArr[id] = op + setEquation(eqArr) + },[op]) + return <> {operator} @@ -25,9 +39,19 @@ function EquationOperator(p) { function EquationValue(p) { const {equation,setEquation,data,val,key,id} = p - return <> + const [item,setItem] = useState(val) + + useEffect(()=>{ + var eqArr = [...equation] + eqArr[id] = item + setEquation(eqArr) + },[item]) + + return
+ {val} +
{data[val]} - +
} function Equation(p) {