Hello everyone!
Again about lifecycles. I've searched and read about lifecycle deprecation and, yes, I can understand technological point of view why it should be deprecated. I saw author opinion that recompose is not state management lib or replacement for classes. But why we are not allowed to use recompose to replace classes just from point of view of style? I am sure there are a lot of people who just like to write components that consist out of only functions. Personally I don't like classes, this, bind, super, etc. But I really like how components look when composed from recompose utils. What do you think?
Also it little bit weird that half of my components are classes and other one are functions (I mean complex ones with state and a whole bunch of handlers). And I am concerned about rewriting components when lifecycles is needed. Imagine I wrote component with state using withStateHandlers, covered it with tests. But at some point of time, for example, I need to add componentDidMount lifecycle. In this case I have to rewrite whole component and also its tests using classes. This is a lot of work I think.
Could you please elaborate how to use recompose properly? Should I avoid writing common components using recompose? Should use it only for HOCs?
I am really appreciate the work you guys have done creating this amazing library!
1) Lifecycle from style pov it doesn't solve any specific problem - it looks like almost exact wrapper over react class, so for me it does not look stylish or somehow good. It always looks like some alien inside composition, it's hard to type it, and source are always looks cleaner without it ;-)
2) About like-dislike something in a language. Few years I haven't used for while cycles in js at all, because I thought that map, filter, reduce are much more cooler, until I realised that in a lot of cases cycles are easier to read, easier to write, and having that language have them why to not use them. So now for hard logic I usually use cycles. The same with classes etc - their are already exist in a language, for some cases it's easier to use classes, and all that OOP is not bad and can be used in a pair with functional programming too.
3) Now about some components are classes some are not. It's a not a strict rule or something, but in my code low level components - controls, etc usually are written on react classes without recompose, and high level components - pages, forms etc are written with recompose.
BTW as it's not a strict rule there are a lot of my controls written on recompose, and there are pages exists which written with React only. If it simpler to write something without additional libraries - it's not so bad to not use them ;-)
And there is no properly way to use something - we are all different, there is no need to be the same. Write code as like as YOU like and YOU think it must be written, and be sure you will find a way and code style which is yours and only yours.
Also don't afraid rewriting, write code easy to delete not to extend.
@istarkov Thanks a lot for the explanation!
for and while cycles are a good example. The same happened to me when I've started to use generators :)
Hmm...I got your point of writing low level components with classes and high-level with recompose. It seems the app I am working now is wrote the same way. I'll stick to this currently though I do like recompose style :)
@istarkov this issue can be closed I think.
Feel free to close ;-)
Most helpful comment
1) Lifecycle from style pov it doesn't solve any specific problem - it looks like almost exact wrapper over react class, so for me it does not look stylish or somehow good. It always looks like some alien inside composition, it's hard to type it, and source are always looks cleaner without it ;-)
2) About like-dislike something in a language. Few years I haven't used
forwhilecycles in js at all, because I thought thatmap,filter,reduceare much more cooler, until I realised that in a lot of cases cycles are easier to read, easier to write, and having that language have them why to not use them. So now for hard logic I usually use cycles. The same with classes etc - their are already exist in a language, for some cases it's easier to use classes, and all that OOP is not bad and can be used in a pair with functional programming too.3) Now about some components are classes some are not. It's a not a strict rule or something, but in my code low level components - controls, etc usually are written on react classes without recompose, and high level components - pages, forms etc are written with recompose.
BTW as it's not a strict rule there are a lot of my controls written on recompose, and there are pages exists which written with React only. If it simpler to write something without additional libraries - it's not so bad to not use them ;-)
And there is no properly way to use something - we are all different, there is no need to be the same. Write code as like as YOU like and YOU think it must be written, and be sure you will find a way and code style which is yours and only yours.
Also don't afraid rewriting, write code easy to delete not to extend.