|
|
|
|
|
by morrvs
2060 days ago
|
|
You bring up an interesting point. I intentionally used "may" in that statement as using .innerHTML can be both effective and performant enough (and a lot simpler). A couple possible problems off the top of my head: 1. CSS transitions won't work if you re-render a complete chunk of HTML instead of toggling a class. 2. <a>, <button>, <input>, etc. may lose focus or even data on re-render (e.g. while filling out a form). 3. Text selection may be reset on re-render. 4. If you don't use event delegation, event listeners may need to be reattached. I agree that for raw display .innerHTML may be sufficient, but it's surely not in general. That would make React almost irrelevant, by the way, which would be a huge surprise. |
|