r/reactjs • u/timmonsjg • 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! π
38
Upvotes
View all comments
Show parent comment
2
u/ozmoroz Dec 16 '18
There are two issues with spreading all your props:
PureComponent). I wrote about re-rendering cycles andPureComponentin details here: What is React.PureComponent and when to use it. So, when you spread props, your child component receives more props than necessary. And if any of them changes (even the ones you component doesn't use), it will trigger a re-render and will slow your application down.<input>. React doesn't like when its DOM components receive unknown props. At minimum you'll get an Unknown Prop Warning. However, if you are unlucky, that may lead to an unpredicted results.Bottom line, you shouldn't spread props unless you know what you are doing, or you are using a library and its documentation instructs you to do so.