@hookers/use-wait-for-element
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@hookers/use-wait-for-element

requires react 16.8+

Wait for a dom element to appear then execute a callback

install

yarn add @hookers/use-wait-for-element
import { useWaitForElement } from '@hookers/use-wait-for-element';

const onClick = () => {
    const demo = document.createElement('div');
    demo.id = 'demoId';
    document.body.appendChild(demo);
}

export const Example: React.FC = () => {
    useWaitForElement('#demoId', () => aleart('callback!'));
    
    return <button onClick={onClick}>Click me</button>;
}

Readme

Keywords

none

Package Sidebar

Install

npm i @hookers/use-wait-for-element

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

7.26 kB

Total Files

14

Last publish

Collaborators

  • tyson-skiba