Skip to content

Commit 654df53

Browse files
committed
fix: add getfieldvariant usememo
1 parent bb11c16 commit 654df53

File tree

1 file changed

+9
-2
lines changed
  • web/src/layout/Header/navbar/Menu/Settings/SendMeNotifications/FormNotifs

1 file changed

+9
-2
lines changed

web/src/layout/Header/navbar/Menu/Settings/SendMeNotifications/FormNotifs/FormEmail.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Dispatch, SetStateAction, useEffect } from "react";
1+
import React, { Dispatch, SetStateAction, useEffect, useMemo } from "react";
22
import styled from "styled-components";
33
import { Field } from "@kleros/ui-components-library";
44

@@ -25,9 +25,16 @@ const FormEmail: React.FC<IFormEmail> = ({ emailInput, setEmailInput, setEmailIs
2525
setEmailInput(event.target.value);
2626
};
2727

28+
const getFieldVariant = useMemo(() => {
29+
if (emailInput === "") {
30+
return undefined;
31+
}
32+
return emailIsValid ? "success" : "error";
33+
}, [emailInput, emailIsValid]);
34+
2835
return (
2936
<StyledField
30-
variant={emailInput === "" ? undefined : emailIsValid ? "success" : "error"}
37+
variant={getFieldVariant}
3138
value={emailInput}
3239
onChange={handleInputChange}
3340
placeholder="youremail@email.com"

0 commit comments

Comments
 (0)