Passing function to create new component to child using react hooks

The bug is in your ArrowForm

        <input type="submit" 
onSubmit= {newArrow([...arrows, <Arrow x="75" y="100"/>])} />

it means as soon as your component render call onSubmit instead you have to do this:

        onSubmit={() => newArrow([...arrows, <div x="75" y="100" />])}

Here is the demo. See console. As I don’t know what is your arrow component do.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top