The 8 tips in order. 1. Setup Linting @ 1:00 2. Set propTypes & defaultProps @ 4:15 3. Know when make a new component @ 6:00 4. component vs pureComponent vs Functional Stateless Component @ 8:14 5. React DevTools @ 11:27 6. Inline Conditionals @ 12:30 7. Use Snippets @ 15:00 8. Learn how React works @ 16:25 To learn all about React, check out React 16 For Everyone goo.gl/MkRA11
@maxipop10007 жыл бұрын
JS ternary is: condition ? expr1 : expr2 not condition : expr1 : expr2 :)
@mathewcohen30617 жыл бұрын
Oh good, someone else point this out.
@goblinlordx61086 жыл бұрын
On 4 your explanation of PureComponent is pretty far off. So far off I would say it is flat out incorrect. React does no such thing as "deep checking". A component will render whenever render is called. There are specific conditions that cause this but in general it is from setState being called within the same component or a parent/ancestor. Once render is called on a component, it will call render on child componens. There is no checking here at all. PureComponent just extends the Component class and implements the shouldComponentUpdate hook. It implements this using a shallow comparison of all props passed. This check is shallow so for objects/arrays this will impact things negatively if in the parent an object was modified instead creating a new object (modified has same reference). This would cause the shallow comparison to pass and it would prevent rerender. When used properly, this prevents further rendering of a branch of the component tree (where the shouldComponentUpdate hook stopped it). Either way... I kind of stumbled on your videos but for someone teaching the material I am pretty shocked at the way you explained it.
@nemethmik6 жыл бұрын
Goblinlordx, you might be right, but, believe me, with even his errors here and there he is much smarter than most "star" Udemy trainers on React/Redux/JS. Udemy courses were a big disappointment to me.
@goblinlordx61086 жыл бұрын
@@nemethmik I can't really comment on anything Udemy related as I have never used Udemy before. I completely believe you though.
@hamzahajji58147 жыл бұрын
14:20 line 56 the right syntac is condition ? exp : exp2
@syntaxfm7 жыл бұрын
Ugh. I can't believe I did that. Thanks.
@academiereparation36627 жыл бұрын
I thought this is a new ES7 feature :)
@KhogaEslam6 жыл бұрын
i was about to write that comment too :D
@ubibecauseofai78645 жыл бұрын
Great video - this was perfect for someone like me who is bored with the beginner tutorials but who isn’t quite knowledgable enough to be considered an expert.
@DEVDerr5 жыл бұрын
9. Use Typescript and replace propTypes with interfaces :)
@DaveCool2477 жыл бұрын
Good stuff Scott! I'd also recommend prettier. I just switched to it and it is LIFE CHANGING. Set it up to format on save and you'll never want to code JavaScript without it again.
@syntaxfm7 жыл бұрын
Def! Even better is the Prettier plugin for ESLint.
@luisrodriguezcastro38036 жыл бұрын
I am very very glad you create your themes based on Wes Bos theme. Yours and Wes Bos's are the only themes that don't make my eyes hurt. Great video.
@cis84muz7 жыл бұрын
We want more! :) What I am missing is a tool that would show me a tree of components of my application in graphical form. You know, I have 50-60 components and I start to forget which components was related to which. So a tool that would generate me a road plan of my work.
@invntiv5 жыл бұрын
React Dev Tools for Chrome extension will do this for you
@SowedCastelli6 жыл бұрын
Thank you for the great pointers. Man, your audio setup is amazing!
@AlistairCerio6 жыл бұрын
In setting propTypes, how do you handle props from Redux? These are props from mapStateToProps & mapDispatchToProps? Do you add them to propTypes everytime?
@Skywalker37ful4 жыл бұрын
Thanks for the informative video, what's the theme of vs code you're using?
@etayluz6 жыл бұрын
Regarding the use of inline conditional statement to render a component (minute 12:35), isn't this going to insert and remove the component from the DOM in real time? Isn't it better to hide and show using CSS's style={display: 'none'} from a performance point of you? I'm not disputing the merit of inline conditionals - just that in this specific use case it does not seem optimal.
@syntaxfm6 жыл бұрын
If you just have display none that component and all of it's children will be rendered by React. In this instance if I'm not an affiliate, why would I want to render that component and all of it's children only to be not displayed. Also if the user isn't an affiliate, they might not have the data requirements to make that component even render correctly. IMO this is the perfect way to use inline conditionals.
@yashone74 жыл бұрын
eventually, there will be some files with long lines of code? Or not? extracting component logic for reusability is really tricky
@syntaxfm4 жыл бұрын
You can extract all kinds of logic now with React hooks.
@patrasculucian24036 жыл бұрын
4:43 - Referring to "userIsLoaded: false,". It is the only pair from that object. Why do you get an error if you don't put a comma there?
@lorenzogiulioni94756 жыл бұрын
maybe I'm late but it's about trailing commas on multiline statements: medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
@Zombieskelper7 жыл бұрын
What is putting the sizes of the imports in your file?
@syntaxfm7 жыл бұрын
Import Cost. It's a VSCode extension.
@lsagar5 жыл бұрын
Do you have tutorial for making website with react like the one at 0:30
@thatguynar6 жыл бұрын
What plugin did you use to show the compressed file size?
@KhogaEslam6 жыл бұрын
i like tools you are using. 1 comment is about tip @14:50 conditional rendering works with false, null and undefined values. but, Not 0 (falsely value) it will just render. ex: {myArray.length && } will always display MyComponent as if length is zero won't be considered as False condition
@derocknc7 жыл бұрын
what font are you using to have the arrow function connect like that?
@coffeegerm7 жыл бұрын
derocknc Fira code with litigations enabled
@sangeethks5545 жыл бұрын
Which is that vs theme??
@liquidtags5 жыл бұрын
Search for level up tuts theme
@NoelTorres_noletorious5 жыл бұрын
its crazy to think how far react has changed since 2017.
@sarscov98543 жыл бұрын
I'm seeing this in 2021 lol. They didn't use hooks back then or have useEffect? Damn.
@JasonSchoeman7 жыл бұрын
Nice video, gave me very good tips. Thanks a lot.
@dragerot6 жыл бұрын
Thanks for the video. Very good tips
@alekseikorkh90107 жыл бұрын
Hi Scott. Thanks for the great video !:)
@ahmadaziz18007 жыл бұрын
Which theme are you using?
@jeffersonribeiro16696 жыл бұрын
whant to know too
@jeffersonribeiro16696 жыл бұрын
found it, he made it: The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup
@snugglepuff337 жыл бұрын
Wow these are some really great tips! What color theme is that?
@syntaxfm7 жыл бұрын
The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup made by yours truly.
@neoesm4 жыл бұрын
“Component verse purecomponent verse a stateless functional component”
@telinixinfopvtlimited75196 жыл бұрын
How can we use react redux with laravel it is good for scalable application like admin panel ?
@syntaxfm6 жыл бұрын
Good Q. I haven't used Laravel much myself so I'll need someone else to answer if possible.
@merodiro6 жыл бұрын
Balaji Pastapure Php artisan preset react And then add redux as normal
@emmanuel46997 жыл бұрын
where do you buy your shirts? They're so nice
@syntaxfm7 жыл бұрын
Good q. Mostly H&M. Occasionally JCrew, but only the outlet really.
@engelshentenawy7 жыл бұрын
What is your vscode setup ?
@jeffersonribeiro16696 жыл бұрын
Whats the name of your editor code theme?
@syntaxfm6 жыл бұрын
Level Up official
@manuelpascual70634 жыл бұрын
I use native javascript default param values instead of default prop types. Anyone else following this approach? It saves me the headache of declaring another object and obviously lines of code 🤓
@mouadbaha-eddine94717 жыл бұрын
What color schemes are u using ?
@syntaxfm7 жыл бұрын
The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup made by me.
@mouadbaha-eddine94717 жыл бұрын
thanks it's cool
@Daijyobanai7 жыл бұрын
Going to come back to this video once I've gone through the React 16 4 evry1 challenge. Cos some of this just bounced right off.
@willy-mp5bm6 жыл бұрын
no dangling underscore! about ~4:30! Bad!
@syntaxfm6 жыл бұрын
Why is it bad? What about it is bad? Is it just that a linter said not to use it?
@papa_ethan2 жыл бұрын
9) Always do it in Typescript.
@syntaxfm2 жыл бұрын
Agreed!
@vamshicholleti67576 жыл бұрын
Can anyone tell me that "How can we get directory path by clicking browse button in Reactjs" ??
@Vincepp7 жыл бұрын
9. Start breakdancing.
@syntaxfm7 жыл бұрын
I can't say it doesn't help.
@benbaldivia92036 жыл бұрын
The explanation PureComponents in 4 was incorrect. React does no such thing as "deep checking". Once render has been called on any component (usually by a call to setState) it will call render on all children. The children will do the same and in this way render the entire tree of components. There is absolutely no "checking" involved here at PureComponent extends the shouldComponentUpdate hook. It is implemented in PureComponent by doing a shallow comparison on all props. If this shallow comparison of props passes (all are determined equal) it will prevent calling render on that component. In that way, it will prevent rendering all children (because render isn't called initially on that component). The performance gained is from preventing rendering and not from preventing any sort of checking or "deep checking".
@syntaxfm6 жыл бұрын
I'm not sure I get what your problem is with my explanation. reactjs.org/docs/react-api.html#reactpurecomponent. PureComponent prevents renders by not checking prop difference more than 1 level deep. "React.PureComponent implements it with a shallow prop and state comparison." You might be getting hung up on the word phrase "deep checking". "There is absolutely no "checking" involved here" - React's official docs disagree with that statement. It's a shallow prop comparison.
@benbaldivia92036 жыл бұрын
From that same page: "The difference between them is that React.Component doesn’t implement shouldComponentUpdate(), but React.PureComponent implements it with a shallow prop and state comparison." In component, "shouldComponentUpdate" is not implemented. It does nothing. When render is called on a component, it will trigger a state change on children. The state change will trigger calling render. There is no checking going at all in "Component". The notice is simply saying that the checking that IS done in PureComponent is only shallow. It is not saying that it does "deep checking" in Component. In fact, it specifically states it "doesn't implement shouldComponentUpdate()". Here in github we can see where "shouldComponentUpdate" is called. We know the API is return "false" to prevent calling render and return "true" to indicate render should be called. github.com/facebook/react/blob/dbd16c8a9624731a5e4ecadc9eef6c0e2d225d84/packages/react-reconciler/src/ReactFiberClassComponent.js#L228 (note this code was much more strait forward before Fiber was introduced) We can see here, when "shouldComponentUpdate" is a function type (basically, when it was declared) then it will call it. A few lines down you will see "ctor.prototype.isPureComponent". This is a simple flag which PureComponent adds to the class. When this flag is set, it returns the result of "shallowEqual" of props and state. This is "PureComponent"'s implementation of "shouldComponentUpdate". If "shouldComponentUpdate" is not a function (default of any Component as it would be undefined if not declared by dev) then the result of this is simply to return "true". As we stated earlier, when "shouldComponentUpdate" it simply means "go ahead and call render". There is absolutely no additional "checking" and certainly no "deep checking". The performance gained is the preventing of calling render on a component which will trigger updates on all children (which will go through this same cycle and call all relevant lifecycle hooks). I would note, calling "render" is done before any "virtual dom" diffing. That is still done after the entire tree is rendered to determine what should actually be changed in the browser.
@benbaldivia92036 жыл бұрын
In reviewing the video again I will state specifically what you were saying that is doesn't seem to be correct: kzbin.info/www/bejne/eJ_Gfnlolrl_Ztkm51s 1. "If you're wondering about a PureComponent vs. a normal Component... well a PureComponent doesn't do deep checking..." - Neither PureComponent nor the base class Component do "deep checking" so this is most definitely not a difference 2. "when a Component gets new props into it, it usually rerenders" - The base Component class doesn't do anything to prevent calling render once an update cycle has started. Unless the user (dev) implemented "shouldComponentUpdate" and returned "true" it will call render regardless of there being any new/old/no props. 3. Then you continue explaining "deep checking" as if it were happening somewhere in the implementation when it (as previously I mentioned) does not. Component does nothing. PureComponent implements "shouldComponentUpdate" using a shallowEqual of props and state. That is not what you stated. More importantly, I think it is important to state "shouldComponentUpdate" is not implemented in the base Component class and that it is in PureComponent. Also, I know this probably seems like excessive complaining. I do appreciate the videos you have created. I think in general they are pretty high quality material. ^^
@vonoom4 жыл бұрын
Note to self: 12:30
@willy-mp5bm6 жыл бұрын
inline conditionals (&&) -> greatly dislike. Much prefer a {checkRenderAbcd()} and then do the conditional in a function higher up. Much cleaner and more importantly, there's no 'what does it mean?' aspect, when Jr/New react devs are looking at it.
@syntaxfm6 жыл бұрын
I totally disagree. {somefunc()} pulls you out of the context of the component tree. Teaching what && does is not a huge burden and can be done in minutes while saving a ton of unneeded code.
@xaapt6 жыл бұрын
that was helpful
@bramskiebiet6 жыл бұрын
Nice😀
@FajnyAleZaNiski7 жыл бұрын
+1, Hi Scott :-)
@nlgachu75364 жыл бұрын
TypeScript in 2020 please
@nikeshsraj4 жыл бұрын
Haven’t watched the video yet. But how relevant is this in 2020??
@zoommair6 жыл бұрын
Why did you update bruh? lol
@etayluz6 жыл бұрын
what's with the glasses?
@syntaxfm6 жыл бұрын
I wear them to see.
@sagar-gavhane6 жыл бұрын
Html to Jsx convertor and snippets
@ImTheBatchMan4 жыл бұрын
Clicked because I got you confused with iDubbbz
@chanlito48967 жыл бұрын
Join us cool kids use standardjs
@matiaslauriti4 жыл бұрын
Just 1 tip to get better at react: use vue
@edvinsantonovs7 жыл бұрын
"Set propTypes & defaultProps" can be replaced with Flow. Everyone who use React should use Flow.
@syntaxfm7 жыл бұрын
I don't know if I'd say "everyone" should use Flow. I think type checking yes. But I don't think there is a clear winner yet between TypeScript, Flow, Reasonml, ect. Flow is great, but I don't think it's a requirement specifically.
@roach_iam7 жыл бұрын
You should also know that propTypes show errors at runtime as well which flow does not. Why not just use both?!
@ralexand566 жыл бұрын
No, everyone should use typescript. It supports features that usually end up being part of standard javascript. ;)