September 2018
Intermediate to advanced
328 pages
9h 10m
English
The fourth section contains functions that calculate and update the balances object in global state:
... updateInitialBalance(amount, fieldName) { this.state.balances[fieldName] = amount; }, // Update the "balances" object in global state based on the current // initial balances: recalculateBalances() { const { initialRaw, initialCooked } = this.state.balances; const { currentRaw, currentCooked } = this.wasm.getCurrentBalances( initialRaw, initialCooked ); this.state.balances = { initialRaw, currentRaw, initialCooked, currentCooked }; }};
The updateInitialBalance() function sets the property value in the balances object in global state based on the amount and fieldName arguments. The recalculateBalances() function updates ...
Read now
Unlock full access