Undo an animation on button click – motion framer

  javascript, onclick, reactjs

Here is my code –> https://codesandbox.io/embed/gallant-violet-hhokb?fontsize=14&hidenavigation=1&theme=dark

Its look terrible but its only to show my problem. When u click "about us" from menu animation starts and this is fine. But how to undo this animation when user click "back" button? Actually when u click button animation just hidden without any animaiton and this looks bad. i searched answer for my question in other topics and documentation but i dont find it. Can anyone explain/show for me how to do this?

Thanks in advance for your comments!

Source: Ask Javascript Questions