if I have an <button onClick={method}>
//method method () => {<ul> {array.map(item => <li key={item}>{item}</li>)} </ul>}
// app.js
<div> <ul> // how should i print the method here when button is clicked </ul> </div>
so how should i print this method on a specific <div> or <ul> when button is clicked
I would rather set a state variable and in render just react on the changed state and render the stuff you now have put into your method.
TheSheriff
Co-Founder, Founder, Entrepreneur & Problem Solver
let node = document.createElement('')parentNode.appendChild(node)You could also use
insertBefore()if you wish to do something other than just adding a new element to the end of the list.