In your code, there a number of confusing state management patterns from the child and App component.
I have updated your code in the sandbox here https://codesandbox.io/p/sandbox/w9lvkr