Skip to content

Commit

Permalink
fixed warning for useEffect dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Medesan committed Dec 2, 2020
1 parent 4c87839 commit 2358c73
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/ProgressWorkflow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@ const ProgressWorkflow = (props) => {
const setVisibleSide = () => {
setVisible(!visible);
};
const findCurrentState = (steps, done) => {
const arrayContainingCurrentState = steps.find(
(itemElements) => itemElements[1] === done,
);
const indexOfCurrentSateKey = arrayContainingCurrentState[0].indexOf(
currentStateKey,
);
const title = arrayContainingCurrentState[2][indexOfCurrentSateKey];
const description = arrayContainingCurrentState[3][indexOfCurrentSateKey];

setCurrentState({
done,
title,
description,
});
};

useEffect(() => {
const findCurrentState = (steps, done) => {
const arrayContainingCurrentState = steps.find(
(itemElements) => itemElements[1] === done,
);
const indexOfCurrentSateKey = arrayContainingCurrentState[0].indexOf(
currentStateKey,
);
const title = arrayContainingCurrentState[2][indexOfCurrentSateKey];
const description = arrayContainingCurrentState[3][indexOfCurrentSateKey];

setCurrentState({
done,
title,
description,
});
};

// filter out paths that don't have workflow (home, login etc)
if (
workflowProgress.result &&
Expand All @@ -53,7 +54,7 @@ const ProgressWorkflow = (props) => {
setCurrentState(null); // reset current state only if a path without workflow is
// chosen to avoid flicker for those that have workflow
}
}, [workflowProgress]);
}, [currentStateKey, workflowProgress]);

useEffect(() => {
dispatch(getWorkflowProgress(pathname)); // the are paths that don't have workflow (home, login etc)
Expand Down

0 comments on commit 2358c73

Please sign in to comment.