@rfilenko
Posted
Hey, George, I've looked into your code - to update score you need to:
- in App.js delete setScore here: function newGame(result) { setSelection(''); // setScore(score + result); }
- in Results.js, pass all needed props and update score with useeEffect like so: useEffect(() => { props.setScore(props.score + result); }, [result])
This way score will be updated in Scoreboard as well. Also consider refactoring a bit your js code.
Cheers, Roman
@georgehobbs
Posted
@rfilenko Thanks. I fixed it by ensuring the Result component re-rendered with the same weapon for the house (by adding state for the compWeapon in App.js). Works better now.