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

refactor: improve readability #64

Open
wit03 opened this issue Oct 9, 2024 · 0 comments
Open

refactor: improve readability #64

wit03 opened this issue Oct 9, 2024 · 0 comments

Comments

@wit03
Copy link
Member

wit03 commented Oct 9, 2024

          _:hammer_and_wrench: Refactor suggestion_

Consider simplifying the checkbox onChange handler.

The current implementation creates a new function for each checkbox, which might impact performance for large lists. Consider lifting this function out of the map callback for better performance.

Here's a suggested improvement:

+ const handleCheckboxChange = (value: string) => () => {
+   handleChangeMultiplyOpenSource(value);
+ };

  {multiplyOpenSource.map((item, i) => (
    <div key={i}>
      <Checkbox
        key={i}
        label={item.name}
        value={item.name}
        className="cursor-pointer"
        checked={checkBox.multiplyOpenSource === item.name}
-       onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
-         handleChangeMultiplyOpenSource(e.target.value)
-       }}
+       onChange={handleCheckboxChange(item.name)}
      />
    </div>
  ))}

This change will create only one function per render cycle instead of one per checkbox, potentially improving performance.

Committable suggestion was skipped due to low confidence.

Originally posted by @coderabbitai[bot] in #46 (comment)

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

No branches or pull requests

1 participant