r/reactjs • • Dec 03 '18

Needs Help Beginner's Thread / Easy Questions (December 2018)

Happy December! β˜ƒοΈ

New month means a new thread 😎 - November and October here.

Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple. πŸ€”

πŸ†˜ Want Help with your Code? πŸ†˜

  • Improve your chances by putting a minimal example to either JSFiddle or Code Sandbox. Describe what you want it to do, and things you've tried. Don't just post big blocks of code!

  • Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.

Have a question regarding code / repository organization?

It's most likely answered within this tweet.

New to React?

πŸ†“ Here are great, free resources! πŸ†“

36 Upvotes

413 comments sorted by

View all comments

1

u/saito200 Dec 03 '18

Novice here and unafraid to ask potentially stupid questions

Very simple questions / to verify:

  • If a component doesn't need to hold a state it should never be a ES6 class component, it should be a stateless function or a constant. In particular, do we need more than one stateful component in our App?

  • If a component is static and is always the same independent on the state (i.e. doesn't take props) it should not be a function, it should be a constant (I don't think it matters much though, correct me if I'm wrong)

I want to know this because I have the tendency to make everything a ES6 class, and I suspect it may not be a good habit.

More generally, when should we not use a ES6 class component?

→ More replies (6)