Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Add useEffect for action state sync #1600

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

ibolton336
Copy link
Member

Resolves https://issues.redhat.com/browse/MTA-1826

  • Uses a useEffect hook to synchronize the state of the action based on the assessment object. This way, whenever assessment changes, we can ensure that the action is recalculated.

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ca600a3) 39.27% compared to head (521fe79) 39.27%.
Report is 1 commits behind head on main.

❗ Current head 521fe79 differs from pull request most recent head 15cf683. Consider uploading reports for the commit 15cf683 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1600   +/-   ##
=======================================
  Coverage   39.27%   39.27%           
=======================================
  Files         146      146           
  Lines        4827     4827           
  Branches     1152     1152           
=======================================
  Hits         1896     1896           
  Misses       2917     2917           
  Partials       14       14           
Flag Coverage Δ
client 39.27% <ø> (ø)
server ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ibolton336 ibolton336 merged commit d5bb144 into konveyor:main Dec 11, 2023
4 checks passed
Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious if you tried useMemo instead of useEffect?

It seems like you'd be able to just do the whole thing as a single memo w/o state:

  const action = useMemo(() => {
    if (!assessment) {
      return AssessmentAction.Take;
    } else if (assessment.status === "started") {
      return AssessmentAction.Continue;
    } else {
      return AssessmentAction.Retake;
    }
  }, [assessment]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants