Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@garage-panda/use-await-dom-render

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@garage-panda/use-await-dom-render - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

2

package.json
{
"name": "@garage-panda/use-await-dom-render",
"version": "0.0.7",
"version": "0.0.8",
"description": "React hook that is used to await all DOM elements inside a node to be rendered",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -0,1 +1,3 @@

[![npm version](https://badge.fury.io/js/%40garage-panda%2Fuse-await-dom-render.svg)](https://badge.fury.io/js/%40garage-panda%2Fuse-await-dom-render)
# use-await-dom-render

@@ -30,3 +32,3 @@

React.useLayoutEffect(() => {
React.useEffect(() => {
const targetNode = document.querySelector("#container-component");

@@ -39,2 +41,3 @@

observer.on("dom-update", () => {
// Can be called multiple times
console.log("Each DOM update comes here");

@@ -47,2 +50,6 @@ });

observer.on("load", () => {
console.log("Multiple listeners can be attached, will be called in order.");
});
/**

@@ -63,3 +70,3 @@ * Make sure startWait is called after the attached listeners

return <div id="container-component"></div>;
return <div id="container-component" />;
}

@@ -74,2 +81,19 @@ ```

## Documentation
- `hook useAwaitDomRender(waitTime: number)`
- Returns - Array<`DomObserver`, `StartWaitFunc`>: (example: `[observer, startWait]`);
- Parameters:
- `waitTime: number` - how much time needs to pass with no new DOM updates, after which the `load` event is emitted
- `class DomObserver` (first argument of return array of hook)
- methods
- `on(event: DomObserverEvent, callback: () => void)` - registers an event listener for each dom observer event. Possible events are: `start` , `dom-update` and `load`.
- `removeListeners()` - removes all active previously attached listeners
- `type StartWaitFunc` (second argument of return array of hook)
- `(targetNode: Node) => void` - starts waiting for DOM updates within the provided targetNode.
## Contributing

@@ -76,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc