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

PR for #147 Refactor components to use functional components #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

b18050
Copy link

@b18050 b18050 commented Sep 18, 2024

Fix #147

@ydaniju
Copy link
Contributor

ydaniju commented Sep 20, 2024

Would be great to split this up into smaller PRs for 2 reasons:

  1. Easier to review.
  2. If there is a bug or regression, it's easier to track down the actual change that caused it.

Copy link
Collaborator

@arvinpoddar arvinpoddar left a comment

Choose a reason for hiding this comment

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

Skimmed over this because it's a large PR, but overall looks good.

mounted: false,
};
}
const [language, setLanguage] = useState(getSavedLanguagePreference());
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're using React v18+, we may be able to use useSyncExternalStore, which provides a more robust method for reading data from external systems (like localStorage). I wrote a blog post on this: https://www.arvinpoddar.com/blog/syncing-local-storage-with-react-state

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. I'll be sure to read your blog post for a more in-depth understanding.


handlePopoutOpen = (val) => {
this.setState({ popoutOpen: val });
const handlePopoutOpen = (val) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nit: from a code clarity perspective, I'm of the opinion that it's preferable to have functions declared with function, and reserve const for computed values. Not required to change, just my two-cents (it's highly likely that at some in this code, I was also defining functions with const).

@b18050 b18050 requested a review from salcock September 23, 2024 22:27
@b18050 b18050 marked this pull request as ready for review September 27, 2024 00:16
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.

Refactor code to use functional components
3 participants