Skip to content

Commit

Permalink
Fixed a few instances of useEffect misuse
Browse files Browse the repository at this point in the history
The first parameters were using an arrow function expression without
braces, so the internal expression's return value was being used, and
wasn't a cleanup function for useEffect. This commit should cover all
misuses.
  • Loading branch information
Shadowfiend committed Aug 30, 2023
1 parent 0947b60 commit ce9f103
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion ui/components/Password/PasswordStrengthBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default function PasswordStrengthBar(
const { t } = useTranslation()
const [evaluation, setEvaluation] = useState(0)

useEffect(() => setEvaluation(zxcvbn(password).score), [password])
useEffect(() => {
setEvaluation(zxcvbn(password).score)
}, [password])

const getDescription = useCallback(() => {
if (!password) return t("passwordStrength.strength")
Expand Down
7 changes: 3 additions & 4 deletions ui/components/Shared/SharedAddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export default function SharedAddressInput({
const { errorMessage, handleInputChange, isValidating } =
useAddressOrNameValidation(onAddressChange)

useEffect(
() => handleInputChange(debouncedValue),
[debouncedValue, handleInputChange],
)
useEffect(() => {
handleInputChange(debouncedValue)
}, [debouncedValue, handleInputChange])

return (
<>
Expand Down
7 changes: 3 additions & 4 deletions ui/components/Signing/Signer/TransactionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ export default function TransactionButton({
}
}

useEffect(
() => setUnlockButtons(isTransactionDataReady),
[isTransactionDataReady, setUnlockButtons],
)
useEffect(() => {
setUnlockButtons(isTransactionDataReady)
}, [isTransactionDataReady, setUnlockButtons])

useEffect(() => {
const increaseFocusChangeNonce = () => {
Expand Down

0 comments on commit ce9f103

Please sign in to comment.