Skip to content
14paxton edited this page Aug 10, 2023 · 2 revisions

title: HandleEvents
permalink: ReactNotes/HandleEvents
category: ReactNotes
parent: ReactNotes
layout: default
has_children: false
share: true
shortRepo:

  • reactnotes
  • default


Table of contents {: .text-delta } 1. TOC {:toc}



Add event listener to check if table loads

  1. add in component you are checking
useEffect(() => {      
   window.parent.postMessage({action: 'tGrid-loaded'});      
}, []);      
  1. and in other componenet
     useEffect(() => {      
    window.addEventListener('message', handleMessage);      
      
    return () => {      
        window.removeEventListener('message', handleMessage);      
    };      
}, []);      
  1. Listening for a resizing event
useEffect(() => {      
    if (tableRef?.current) {      
        if (useObserver) {      
            const resizeObserver = new ResizeObserver(async () => {      
                Promise.resolve(buildPPTObject())      
            })      
            if (tableRef?.current) {      
                resizeObserver.observe(tableRef?.current)      
            }      
            return () => {      
                resizeObserver.disconnect()      
            };      
        }      
        else {      
            Promise.resolve(buildPPTObject())      
        }      
    }      
      
}, [tableRef?.current]);      

Clone this wiki locally