When should I be using functional stateless components vs. React class based stateless components?

Write your response…

This answer has received 1 appreciation.

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.

Write a reply...

Join a friendly and inclusive Q&A network for coders

  • 🖥Pick the technologies you like & read great content through your feed.
  • 💬Ask a question when you want to learn more about anything.
  • 🚀Share what you know & build your portfolio.
Sign up nowLearn more

loading ...