Comments (10)
A couple of thoughts:
- Let's base this decision on developer experience and avoiding future rework, not perf. If we're going to make perf decisions, we should measure before and after a fix and base the decision on that.
- There's no harm in making a list like this. At the very least, it will help us really identify the use cases for refs and think some actual examples.
- There's some truth to keeping a low concept overhead. A lot of little simple things can add up to a really complicated thing if you let it. I definitely support using helpers and libraries that make our lives way easier, and we've made some really good picks so far. But we should at least ask if we're spending our concept budget wisely when we explore new things.
from cf-ui.
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.
from cf-ui.
Everything that accepts only primitive types (no arrays or objects) can be PureComponent.
from cf-ui.
If that's the case, do we still want functional components?
from cf-ui.
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...
from cf-ui.
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.
from cf-ui.
export default createComponent(styles, FunctionalComponent);
to
export default createComponent(styles, pure(FunctionalComponent));
is "drastic" and hard to wrap our heads around ?
functional components for simple stupid stateless shit that still remain
Frankly, I don't know what "stupid stateless shit" is anymore. I thought it's stuff like heading
or button
or almost any cf-ui component. Apparently not. I still think that we should not promote usage of refs by default (if that was the main argument for classes). In case you need them, you could use toClass()
.
from cf-ui.
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)
from cf-ui.
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 bike shedding
is a thing.
from cf-ui.
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:
- Have a smaller surface area for bugs
- Are easier to test
- Easier to reason about
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.
from cf-ui.
Related Issues (20)
- Migrate `cf-component-progress` to fela.
- Migrate `cf-component-list` to fela. HOT 1
- `cf-component-label` throws an error HOT 3
- CHANGELOG for components? HOT 5
- Fixed HEX codes in `cf-style-const` HOT 15
- Fix snapshot tests to not to generate new class name hashes
- Performance metrics of smart CSS in JS HOT 4
- [Question] Query regarding the approach taken for styleguide HOT 4
- Rename cf-style-container HOT 2
- Convert cf-component-form back to React component classes HOT 1
- Icon sizes are wrong in cf-component-icon HOT 5
- Migrate `cf-component-link` to fela. HOT 1
- Migrate `cf-component-icon` to fela. HOT 2
- Missing cf-component-viewport and flex HOT 4
- Fix invalid propType error on input HOT 1
- Enforce commit messages in CI HOT 1
- Update README for all Fela components HOT 1
- Fix drop down top arrow HOT 1
- Import strategy in your main applications HOT 3
- Will this repository become updated again? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cf-ui.