May 2024
Beginner to intermediate
384 pages
9h 29m
English
What happens when you’re handling an event in a component that requires a couple of lines of code? One-liners, like this one, look fine inside the virtual Document Object Model (DOM) definition:
render() {
const { count } = this.state
return hFragment([
h(
'button',
{ on: { click: () => this.updateState({ count: count - 1 }) }} #1
['Decrement']
),
h('span', {}, [count]),
h(
'button',
{ on: { click: () => this.updateState({ count: count + 1 }) }} #2
['Increment']
)
])
}