Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

[Discussion/Documentation] Why is use of lifeCycle() considered an escape hatch? #285

Closed
sdtsui opened this issue Dec 6, 2016 · 2 comments

Comments

@sdtsui
Copy link

sdtsui commented Dec 6, 2016

Not sure if this is a dumb question -- apologies in advance if so. It's a beginner question, but unrelated to #264.

Say I want to add an ajax call to my widget's componentWillMount. If this use case + a propTypes declaration is all I need, why not implement with only recompose functions and a stateless component? What's the idiomatic way to write a component with only these two requirements (propTypes, componentWillMount)?

See title: why is use of lifecyclean escape hatch? Should I default to using a class here? Source is the docs, and remembering part of @acdlite 's ReactEurope talk (timestamped) where how he observed "excessive" overuse of HoCs. More generally, what are things I should always do in classes? What is the set of things I can do in HoCs, and how can I learn more about the subset of cases where I can do something with a HoC but should use a class instead?

My team is new to recompose, uses classes for almost everything, and is very open to new ideas. We're starting a new, fairly large project. I'd be extremely appreciative of some context to help inform our standards/conventions. Genuinely interested and hoping to learn more about how to use this library. Happy to summarize add a PR to the docs if this discussion merits it.

Thanks!

@istarkov
Copy link
Contributor

istarkov commented Dec 6, 2016

Hi!

  1. componentWillMount is not a good place for ajax calls, and I'm talking not even about server rendering, but here is a good discussion about.
  2. IMO No idiomatic way how you will write your components, it depends on your code style, on component requirements, usage etc.
  3. lifecycle please read IMO this enhancer not needed at all.
  4. what are things I should always do in classes IMO every time you need refs, window like event processing ('resize' etc), or aggressive code optimizations you should use classes. For some controls you can publish it's not bad to avoid external dependencies.

Just be easy, think less about idiomatic ways and other things, try different solutions, there is no need to be on edge case and use only functional components and recompose.

My team use recompose because it makes code linear and more readable, it took some time before every team member started to love this library ;-)

Good day!

@wuct
Copy link
Contributor

wuct commented Feb 28, 2017

I am going to close this issue because it's no longer active. Please feel free to reopen it.

@wuct wuct closed this as completed Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants