Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 560 Bytes

event-propagation.md

File metadata and controls

22 lines (16 loc) · 560 Bytes

Event Propagation

In the example of introduction, when press command+k when focus is on child, you will see the handlers of both child and parent are called. Use e.stopPropagation to avoid event propagation from child.

  showChildDocumentation = (e: KeyboardEvent) => {
    console.log('show child doc')
    e.stopPropagation()
  }

Or simply return false

  showChildDocumentation = () => {
    console.log('show child doc')
    return false
  }

this is the same as e.stopPropagation() + e.preventDefault()