-
Notifications
You must be signed in to change notification settings - Fork 81
Functional components #162
Comments
Everything that accepts only primitive types (no arrays or objects) can be PureComponent. |
If that's the case, do we still want functional components? |
Yes, you can use the same optimization for functions too - see pure. It's even more idiomatic. In fact, we could keep all components functional and in cases you really need refs you can use toClass HOC. There are many more sweet helpers for functional components in recompose but we can't use them anymore... |
1 thing at a time. There are way too many libraries and APIs we have to wrap our heads around already. How about this: PureComponents for what we can first, functional components for simple stupid stateless shit that still remain? Prepending "Pure" to "Component" seems a lot less drastic to me. |
export default createComponent(styles, FunctionalComponent); to export default createComponent(styles, pure(FunctionalComponent)); is "drastic" and hard to wrap our heads around ?
Frankly, I don't know what "stupid stateless shit" is anymore. I thought it's stuff like |
I was referring to the changing of classes to functions. We do not promote ref usage. I don't know what will remain, just there will be plenty of simple stupid stateless shit like ModalHeader. ("shit" was added for effect, don't take it seriously) |
A couple of thoughts:
|
I deliberately tried to steer the discussion towards something we can measure, like perf. I don't know how to measure DX and predict the future. We all have different mental models, and I don't buy into any holy war arguments that one way is definitely better than the other. Functions are simple, but it is also because they are too simple, we'll need an extra library to help us do the things we can already do in React. I can say converting all classes to function wholesale is definitely going to be more work now. If some work is deemed necessary, the only difference is when to do it. I'm not yet convinced it's necessary to convert all classes to functions. I'm also against doing this during the transition to fela. However, if some people want to do it, let's have this discussion now. I'm willing to compromise, and ready to be convinced. The only thing I'm not okay with is introducing drastic, breaking changes without discussion. |
I am happy with whatever decision we will make here, at this point it's too minor to spend much time on it, please don't forget, we all humans and |
I'm hesitant to use 3rd party libraries like recompose for things we can accomplish easily without them. Not all of our components can be converted to stateless functions and there is no reason we need an all or nothing approach. I'm in favor of converting any component that can be stateless to be stateless. To the developer experience point stateless components:
I think we should wait until the Fela migration is complete, make a list of everything that depends on refs like @jculvey said, and convert the rest to stateless. |
Related to #161
Let's ID a list of components we have a high degree of confidence we'll never need the ref, then convert them to functional components, or if we can, PureComponents, so they can be faster now without having to wait for Fiber.
The text was updated successfully, but these errors were encountered: