Skip to content

Commit

Permalink
fix: set hasErrors useState default to null, use explicit hasErrors==…
Browse files Browse the repository at this point in the history
…=false for condition check
  • Loading branch information
dleard committed Aug 5, 2020
1 parent 6da89b5 commit 68943d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
applicationOverrideJustification: string;
revisionId: string;
relay: RelayProp;
hasErrors: boolean;
hasErrors: any;
}

export const ApplicationOverrideJustificationComponent: React.FunctionComponent<Props> = ({
Expand Down Expand Up @@ -80,7 +80,7 @@ export const ApplicationOverrideJustificationComponent: React.FunctionComponent<
};

useEffect(() => {
if (overrideJustification && !hasErrors) handleOverrideDelete();
if (overrideJustification && hasErrors === false) handleOverrideDelete();
});

const errorsWithOverrideActive = (
Expand Down Expand Up @@ -188,7 +188,7 @@ export const ApplicationOverrideJustificationComponent: React.FunctionComponent<
);

const renderOverride = () => {
if (!hasErrors) return null;
if (hasErrors === false) return null;
if (hasErrors && overrideActive) return errorsWithOverrideActive;
return errorsWithoutOverrideActive;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Pro
const [copySuccess, setCopySuccess] = useState('');
const [url, setUrl] = useState<string>();
const [isChecked, toggleChecked] = useState(true);
const [hasErrors, setHasErrors] = useState(false);
// State of hasErrors is set to null until the child component ApplicationDetailsContainer returns a valid true/false decision
const [hasErrors, setHasErrors] = useState(null);
const copyArea = useRef(null);
const revision = props.application.latestDraftRevision;
const [overrideActive, setOverrideActive] = useState(
Expand Down

0 comments on commit 68943d5

Please sign in to comment.