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

use function instead of class in component #114

Open
cometta opened this issue Mar 14, 2016 · 4 comments
Open

use function instead of class in component #114

cometta opened this issue Mar 14, 2016 · 4 comments

Comments

@cometta
Copy link

cometta commented Mar 14, 2016

Hi guys,
What do you think about using this pattern in meatier https://github.com/ghengeveld/react-redux-styleguide#components-and-containers

example of component /meatier/src/universal/modules/kanban/components/Kanban/Kanban.js

@mattkrick
Copy link
Owner

Yeah, it's a great pattern & i'm all for moving in that direction. The reasons they currently aren't functions are:

from that last bullet point, this is worth a read: https://medium.com/@dan_abramov/hot-reloading-in-react-1140438583bf#.vapjtcgk7

like any big idea, it's worthwhile to let the dust settle for a couple weeks to see how the whole community handles the decision & based on community response, it may be worthwhile to use the lower-level HMR api instead. i like where your head's at though!

@wenzowski
Copy link
Contributor

Could someone explain the value of this pattern over multiple render functions in a class, or point me in the right general direction? Will a future version of react assume all functional components are pure, perhaps?

@wenzowski
Copy link
Contributor

Found stateless functional components so I'm assuming a future version of React will check argument equality before rerunning a functional component?

@mattkrick
Copy link
Owner

it goes back to the idea of smart vs. dumb components. smart ones need lifecycle methods & HOCs & all the joys of classes. Dumb ones take in props & spit out HTML. In theory, a pure function takes less memory & rerenders faster than a class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants