React lets you build user interfaces out of individual pieces called components. Create your own React components like Thumbnail, LikeButton, and Video. Then combine them into entire screens, pages, and apps.
How to reproduce it
<Element onClick={ setOutput('') } ></Element>
Error
Warning: Cannot update a component (`App`) while rendering a different component (`ElementComponent`). To locate the bad setState() call inside `ElementComponent`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
at ElementComponent (http://localhost:3000/static/js/bundle.js:175:5)
at div
at App (http://localhost:3000/static/js/bundle.js:33:88)
Solution
Use the arrow function for the function call. You cannot call the function directly from the event.
<Element onClick={ () => { setOutput('') } } ></Element>