UI = f(state)

Click the button and watch the Virtual DOM object change with state. Note: we're still using innerHTML in this chapter (next chapter will replace it with patch).

Current Virtual DOM snapshot:



  

💡 The button's onclick in the VNode is a function reference (not a string), which is safer than the template era's onclick="increment()" (no XSS risk) and more efficient (can compare references with ===).