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

ScalaComponent.Builder could choose best React component type #515

Open
japgolly opened this issue Jan 19, 2019 · 1 comment
Open

ScalaComponent.Builder could choose best React component type #515

japgolly opened this issue Jan 19, 2019 · 1 comment
Labels

Comments

@japgolly
Copy link
Owner

japgolly commented Jan 19, 2019

Currently it always generates React classes but really, it could be a generic component builder that automatically decided the most appropriate React representation.

  • big win is that many components could be lighter functional components wrapped in React.memo. In my usage, most components are stateless and the only lifecycle method specified is shouldComponentUpdate
  • display name should be optional - not needed for functional components, could be automatically derived anyway (Automatic component name #470 )
  • output type would need to reflect decision meaning it needs to be a type-level calculation meaning we need to track more stuff at the type level meaning install methods that expect to be used by .configure now explode with types meaning yuk
  • would need a method to override automatic selection - users must always have full control
@thien-do
Copy link

Thanks @japgolly this will be huge 👍

most components are stateless and the only lifecycle method specified is shouldComponentUpdate

I have a question: this issue seems that the builder will choose between functional and class component only. Will it possible to generate a class component that extends from PureComponent?

@japgolly japgolly added the should label Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants