I have come to appreciate the simplicity of a React ES6 components. But lately I have come to know from a couple of source that I should use functional stateless components, when I can? Why should I? What benefit do they give me, as opposed to React ES6 class bassed, yet stateless, components?
Write your answer…
As the name says, stateless functions as components have no state management. They are just pure functions executing and returning your JSX. It makes the codebase easier to read and they are faster too for obvious reasons. If a component doesn't need a state, why bloat it with the whole state management.
Here is a good article about that: React Stateless Functional Components: Nine Wins You Might Have Overlooked
You should use stateless components before you use any other Component. If that doesn't work for your component and you need a state, then have a look at Pure Components first. The last option are "normal" components.
Hope this helps.
The Dev Community
Free, friendly and inclusive platform for developers
Or connect with