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

[react] Handling conflict with React built-in props like onCopy #4585

Open
1 task done
augustjk opened this issue Mar 15, 2024 · 0 comments
Open
1 task done

[react] Handling conflict with React built-in props like onCopy #4585

augustjk opened this issue Mar 15, 2024 · 0 comments

Comments

@augustjk
Copy link
Member

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

React (@lit/react)

Description

Brought up by @stefanpearson here #4569 (comment)

React developers using the wrapped components may have expectation that these built-in common props listed here https://react.dev/reference/react-dom/components/common#common would have specific behavior.

If the custom element class has any of those as properties (passes our in check), we set them on the instance rather than pass to React, which might be unexpected.

We could add to the list to reactReservedProperties set which will always pass to React, but if the property is meant to be publicly settable on the custom element, that might then be worse. Our in check can't know the intention. At the very least, adding a dev mode warning could be helpful.

Alternatives and Workarounds

Make sure all internal properties/methods of custom element classes do not conflict with React built-in props. _ prefix or making them private with # are good practices.

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

No branches or pull requests

1 participant