to trigger the animation of the flag on user's selection, a prop would need to be passed from App.jsx to AnimatedComponent so that AnimatedComponent knows when to start animating.
AnimatedComponent is a Higher Order Component (HOC) that i wrote earlier when figuring out how to standardize framer motion animation parameters across all flags displayed. it is used like so: const FlagComponent = AnimatedComponent(svgFlagComponent)
startAnimation state is added and then used as a prop that is passed to the FlagComponent
so when the user clicks on the selection and triggers the checkAnswer function it changes the startAnimation function to true the FlagComponent will re-render and animate the flag!
to trigger the animation of the flag on user's selection, a prop would need to be passed from
App.jsx
toAnimatedComponent
so thatAnimatedComponent
knows when to start animating.AnimatedComponent
is a Higher Order Component (HOC) that i wrote earlier when figuring out how to standardize framer motion animation parameters across all flags displayed. it is used like so:const FlagComponent = AnimatedComponent(svgFlagComponent)
startAnimation
state is added and then used as a prop that is passed to the FlagComponentthen in
AnimatedComponent
it is wrapped by useEffect so that it can trigger the animation whenever the state ofstartAnimation
changes totrue
:so when the user clicks on the selection and triggers the
checkAnswer
function it changes thestartAnimation
function totrue
theFlagComponent
will re-render and animate the flag!