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

Use Ref's for first render checks #959

Open
FancMa01 opened this issue Nov 26, 2024 · 0 comments
Open

Use Ref's for first render checks #959

FancMa01 opened this issue Nov 26, 2024 · 0 comments
Labels
Refactor or Cleanup Refactor or Cleanup code to make code better and more reusable Research

Comments

@FancMa01
Copy link
Collaborator

FancMa01 commented Nov 26, 2024

There are a number of instances in the application where we are checking if it is the first render in order to perform some actions. Ensure these are using Ref's instead of States.

There is potential to create a custom re-usable hook that could help centralize and make code more consistent.

Similar to the following.

function useFirstRender() {
  const ref = useRef(true);
  const firstRender = ref.current;
  ref.current = false;
  return firstRender;
}

More information on the benefits of custom hooks

https://react.dev/learn/reusing-logic-with-custom-hooks

@FancMa01 FancMa01 added Research Refactor or Cleanup Refactor or Cleanup code to make code better and more reusable labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor or Cleanup Refactor or Cleanup code to make code better and more reusable Research
Projects
None yet
Development

No branches or pull requests

1 participant