This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var waitForDOM = function (callback) { | |
| document.addEventListener("DOMContentLoaded", function () { | |
| setTimeout(function () { | |
| callback(); | |
| }, 5000); | |
| }); | |
| }; | |
| var waitFor = function (callbackValue, callback) { | |
| if (callbackValue()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| // REF | |
| const useRefHandler = () => { | |
| const ref = React.useRef(); | |
| const [ready, setReady] = React.useState(false); | |
| const set = (node) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const requiredValues = ["name", "country"]; | |
| const products = [ | |
| { | |
| key: 1, | |
| name: "", | |
| country: "", | |
| }, | |
| { | |
| key: 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useRef } from 'react'; | |
| export function useEventListener<K extends keyof WindowEventMap>( | |
| eventName: K, | |
| handler: (ev: WindowEventMap[K]) => any, | |
| element = global, | |
| ) { | |
| // Create a ref that stores handler | |
| const savedHandler = useRef<(ev: WindowEventMap[K]) => any>(); |