Download ant-design/components/input/hooks/useRemovePasswordTimeout.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 965 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/input/hooks/useRemovePasswordTimeout.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/input/hooks/useRemovePasswordTimeout.ts
-
curl -L -o useRemovePasswordTimeout.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/input/hooks/useRemovePasswordTimeout.ts
965 Bytes
| import { useEffect, useRef } from 'react'; | |
| import type { InputRef } from '../Input'; | |
| export default function useRemovePasswordTimeout( | |
| inputRef: React.RefObject<InputRef | null>, | |
| triggerOnMount?: boolean, | |
| ) { | |
| const removePasswordTimeoutRef = useRef<ReturnType<typeof setTimeout>[]>([]); | |
| const removePasswordTimeout = () => { | |
| removePasswordTimeoutRef.current.push( | |
| setTimeout(() => { | |
| if ( | |
| inputRef.current?.input && | |
| inputRef.current?.input.getAttribute('type') === 'password' && | |
| inputRef.current?.input.hasAttribute('value') | |
| ) { | |
| inputRef.current?.input.removeAttribute('value'); | |
| } | |
| }), | |
| ); | |
| }; | |
| useEffect(() => { | |
| if (triggerOnMount) { | |
| removePasswordTimeout(); | |
| } | |
| return () => | |
| removePasswordTimeoutRef.current.forEach((timer) => { | |
| if (timer) { | |
| clearTimeout(timer); | |
| } | |
| }); | |
| }, []); | |
| return removePasswordTimeout; | |
| } | |