Some equivalent in react for appendchild(). I try ...
# react
f
Some equivalent in react for appendchild(). I try with state but don't work. Any suggestion or tips?
t
child
?
f
I have
<ul>
list and need that every time I call
onclick
event is append
<li>
element in my list.
child
?
child only define child element but not append in nodeList I have managed to do it with React.state but i need declare initvalue of state with my <li> elements. Some simple way to convert HTMLCollection to array or any alternative to React.state?
t
Looks like you want create elements outside
render
method.
Possibly you don't need React? :)
f
@turansky, Possibly you don't need React? :)
My list is react component and need modify DOM for add new item. I understand that I have to use react for modify virtual DOM.
t
DOM change - result of state or props change
Click -> state update -> render -> DOM update
f
@turansky thx, with your last comment I finally understand render cycle and I can clean a lot of redundant code.
👍 1