Skip to content

Refactor useComponent hook to simplify component addition logic #107

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

marklundin
Copy link
Member

Prevents invalid props being passed to the addComponent() method which can create invalid data on a component.

  • Removed unnecessary cloning of props when adding a component to the parent, enhancing performance and clarity.
  • Cleaned up commented-out code to improve maintainability and readability.

Fixes #103

- Removed unnecessary cloning of props when adding a component to the parent, enhancing performance and clarity.
- Cleaned up commented-out code to improve maintainability and readability.
@marklundin marklundin self-assigned this Apr 22, 2025
Copy link

pkg-pr-new bot commented Apr 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/playcanvas/react/@playcanvas/react@107

commit: ae71bb5

@marklundin marklundin added the bug Something isn't working label Apr 23, 2025
@marklundin marklundin requested a review from Copilot April 23, 2025 08:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the useComponent hook to simplify the component addition logic by removing unnecessary prop cloning and cleaning up commented-out code.

  • Removed cloning of props before calling addComponent
  • Updated addComponent call to no longer accept cloned props
  • Cleaned up commented-out code to improve readability

@marklundin marklundin requested a review from Copilot April 23, 2025 08:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the useComponent hook to simplify the logic for adding components and prevent the propagation of invalid props.

  • Removed unnecessary cloning and passing of props to parent.addComponent
  • Cleaned up commented-out code to improve clarity and maintainability

@marklundin marklundin merged commit 7d4b579 into main Apr 23, 2025
6 checks passed
@marklundin marklundin deleted the fix-invalid-component-props branch April 23, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken demo
1 participant