Skip to content

Commit

Permalink
Basics
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalarya873 committed Sep 10, 2024
1 parent b089ce6 commit 022398c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions React-with-Hitesh/05passwordGenerator/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function App() {
const [password, setPassword] = useState("")

const passwordRef= useRef(null);


const passwordGenerator = useCallback(() => {
let result = ""
let str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand All @@ -19,11 +21,15 @@ function App() {
}
return setPassword(result)
},[length, charAllowed, numberAllowed, setPassword])


const copyPasswordtoClickboard = useCallback(()=>{
passwordRef.current?.select()
passwordRef.current?.setSelectionRange(0, length);
window.navigator.clipboard.writeText(password)
}, [password])


useEffect( ()=>{
passwordGenerator()
},[length, numberAllowed, charAllowed, passwordGenerator])
Expand Down

0 comments on commit 022398c

Please sign in to comment.