8 Tips For Getting Better At React

  Рет қаралды 121,241

Syntax

Syntax

Күн бұрын

Пікірлер: 103
@syntaxfm
@syntaxfm 7 жыл бұрын
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
@maxipop1000
@maxipop1000 7 жыл бұрын
JS ternary is: condition ? expr1 : expr2 not condition : expr1 : expr2 :)
@mathewcohen3061
@mathewcohen3061 7 жыл бұрын
Oh good, someone else point this out.
@goblinlordx6108
@goblinlordx6108 6 жыл бұрын
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.
@nemethmik
@nemethmik 6 жыл бұрын
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.
@goblinlordx6108
@goblinlordx6108 6 жыл бұрын
@@nemethmik I can't really comment on anything Udemy related as I have never used Udemy before. I completely believe you though.
@hamzahajji5814
@hamzahajji5814 7 жыл бұрын
14:20 line 56 the right syntac is condition ? exp : exp2
@syntaxfm
@syntaxfm 7 жыл бұрын
Ugh. I can't believe I did that. Thanks.
@academiereparation3662
@academiereparation3662 7 жыл бұрын
I thought this is a new ES7 feature :)
@KhogaEslam
@KhogaEslam 6 жыл бұрын
i was about to write that comment too :D
@ubibecauseofai7864
@ubibecauseofai7864 5 жыл бұрын
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.
@DEVDerr
@DEVDerr 5 жыл бұрын
9. Use Typescript and replace propTypes with interfaces :)
@DaveCool247
@DaveCool247 7 жыл бұрын
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.
@syntaxfm
@syntaxfm 7 жыл бұрын
Def! Even better is the Prettier plugin for ESLint.
@luisrodriguezcastro3803
@luisrodriguezcastro3803 6 жыл бұрын
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.
@cis84muz
@cis84muz 7 жыл бұрын
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.
@invntiv
@invntiv 5 жыл бұрын
React Dev Tools for Chrome extension will do this for you
@SowedCastelli
@SowedCastelli 6 жыл бұрын
Thank you for the great pointers. Man, your audio setup is amazing!
@AlistairCerio
@AlistairCerio 6 жыл бұрын
In setting propTypes, how do you handle props from Redux? These are props from mapStateToProps & mapDispatchToProps? Do you add them to propTypes everytime?
@Skywalker37ful
@Skywalker37ful 4 жыл бұрын
Thanks for the informative video, what's the theme of vs code you're using?
@etayluz
@etayluz 6 жыл бұрын
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.
@syntaxfm
@syntaxfm 6 жыл бұрын
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.
@yashone7
@yashone7 4 жыл бұрын
eventually, there will be some files with long lines of code? Or not? extracting component logic for reusability is really tricky
@syntaxfm
@syntaxfm 4 жыл бұрын
You can extract all kinds of logic now with React hooks.
@patrasculucian2403
@patrasculucian2403 6 жыл бұрын
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?
@lorenzogiulioni9475
@lorenzogiulioni9475 6 жыл бұрын
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
@Zombieskelper
@Zombieskelper 7 жыл бұрын
What is putting the sizes of the imports in your file?
@syntaxfm
@syntaxfm 7 жыл бұрын
Import Cost. It's a VSCode extension.
@lsagar
@lsagar 5 жыл бұрын
Do you have tutorial for making website with react like the one at 0:30
@thatguynar
@thatguynar 6 жыл бұрын
What plugin did you use to show the compressed file size?
@KhogaEslam
@KhogaEslam 6 жыл бұрын
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
@derocknc
@derocknc 7 жыл бұрын
what font are you using to have the arrow function connect like that?
@coffeegerm
@coffeegerm 7 жыл бұрын
derocknc Fira code with litigations enabled
@sangeethks554
@sangeethks554 5 жыл бұрын
Which is that vs theme??
@liquidtags
@liquidtags 5 жыл бұрын
Search for level up tuts theme
@NoelTorres_noletorious
@NoelTorres_noletorious 5 жыл бұрын
its crazy to think how far react has changed since 2017.
@sarscov9854
@sarscov9854 3 жыл бұрын
I'm seeing this in 2021 lol. They didn't use hooks back then or have useEffect? Damn.
@JasonSchoeman
@JasonSchoeman 7 жыл бұрын
Nice video, gave me very good tips. Thanks a lot.
@dragerot
@dragerot 6 жыл бұрын
Thanks for the video. Very good tips
@alekseikorkh9010
@alekseikorkh9010 7 жыл бұрын
Hi Scott. Thanks for the great video !:)
@ahmadaziz1800
@ahmadaziz1800 7 жыл бұрын
Which theme are you using?
@jeffersonribeiro1669
@jeffersonribeiro1669 6 жыл бұрын
whant to know too
@jeffersonribeiro1669
@jeffersonribeiro1669 6 жыл бұрын
found it, he made it: The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup
@snugglepuff33
@snugglepuff33 7 жыл бұрын
Wow these are some really great tips! What color theme is that?
@syntaxfm
@syntaxfm 7 жыл бұрын
The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup made by yours truly.
@neoesm
@neoesm 4 жыл бұрын
“Component verse purecomponent verse a stateless functional component”
@telinixinfopvtlimited7519
@telinixinfopvtlimited7519 6 жыл бұрын
How can we use react redux with laravel it is good for scalable application like admin panel ?
@syntaxfm
@syntaxfm 6 жыл бұрын
Good Q. I haven't used Laravel much myself so I'll need someone else to answer if possible.
@merodiro
@merodiro 6 жыл бұрын
Balaji Pastapure Php artisan preset react And then add redux as normal
@emmanuel4699
@emmanuel4699 7 жыл бұрын
where do you buy your shirts? They're so nice
@syntaxfm
@syntaxfm 7 жыл бұрын
Good q. Mostly H&M. Occasionally JCrew, but only the outlet really.
@engelshentenawy
@engelshentenawy 7 жыл бұрын
What is your vscode setup ?
@jeffersonribeiro1669
@jeffersonribeiro1669 6 жыл бұрын
Whats the name of your editor code theme?
@syntaxfm
@syntaxfm 6 жыл бұрын
Level Up official
@manuelpascual7063
@manuelpascual7063 4 жыл бұрын
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-eddine9471
@mouadbaha-eddine9471 7 жыл бұрын
What color schemes are u using ?
@syntaxfm
@syntaxfm 7 жыл бұрын
The Level Up Theme. marketplace.visualstudio.com/items?itemName=leveluptutorials.theme-levelup made by me.
@mouadbaha-eddine9471
@mouadbaha-eddine9471 7 жыл бұрын
thanks it's cool
@Daijyobanai
@Daijyobanai 7 жыл бұрын
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-mp5bm
@willy-mp5bm 6 жыл бұрын
no dangling underscore! about ~4:30! Bad!
@syntaxfm
@syntaxfm 6 жыл бұрын
Why is it bad? What about it is bad? Is it just that a linter said not to use it?
@papa_ethan
@papa_ethan 2 жыл бұрын
9) Always do it in Typescript.
@syntaxfm
@syntaxfm 2 жыл бұрын
Agreed!
@vamshicholleti6757
@vamshicholleti6757 6 жыл бұрын
Can anyone tell me that "How can we get directory path by clicking browse button in Reactjs" ??
@Vincepp
@Vincepp 7 жыл бұрын
9. Start breakdancing.
@syntaxfm
@syntaxfm 7 жыл бұрын
I can't say it doesn't help.
@benbaldivia9203
@benbaldivia9203 6 жыл бұрын
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".
@syntaxfm
@syntaxfm 6 жыл бұрын
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.
@benbaldivia9203
@benbaldivia9203 6 жыл бұрын
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.
@benbaldivia9203
@benbaldivia9203 6 жыл бұрын
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. ^^
@vonoom
@vonoom 4 жыл бұрын
Note to self: 12:30
@willy-mp5bm
@willy-mp5bm 6 жыл бұрын
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.
@syntaxfm
@syntaxfm 6 жыл бұрын
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.
@xaapt
@xaapt 6 жыл бұрын
that was helpful
@bramskiebiet
@bramskiebiet 6 жыл бұрын
Nice😀
@FajnyAleZaNiski
@FajnyAleZaNiski 7 жыл бұрын
+1, Hi Scott :-)
@nlgachu7536
@nlgachu7536 4 жыл бұрын
TypeScript in 2020 please
@nikeshsraj
@nikeshsraj 4 жыл бұрын
Haven’t watched the video yet. But how relevant is this in 2020??
@zoommair
@zoommair 6 жыл бұрын
Why did you update bruh? lol
@etayluz
@etayluz 6 жыл бұрын
what's with the glasses?
@syntaxfm
@syntaxfm 6 жыл бұрын
I wear them to see.
@sagar-gavhane
@sagar-gavhane 6 жыл бұрын
Html to Jsx convertor and snippets
@ImTheBatchMan
@ImTheBatchMan 4 жыл бұрын
Clicked because I got you confused with iDubbbz
@chanlito4896
@chanlito4896 7 жыл бұрын
Join us cool kids use standardjs
@matiaslauriti
@matiaslauriti 4 жыл бұрын
Just 1 tip to get better at react: use vue
@edvinsantonovs
@edvinsantonovs 7 жыл бұрын
"Set propTypes & defaultProps" can be replaced with Flow. Everyone who use React should use Flow.
@syntaxfm
@syntaxfm 7 жыл бұрын
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_iam
@roach_iam 7 жыл бұрын
You should also know that propTypes show errors at runtime as well which flow does not. Why not just use both?!
@ralexand56
@ralexand56 6 жыл бұрын
No, everyone should use typescript. It supports features that usually end up being part of standard javascript. ;)
@EddyVinck
@EddyVinck 6 жыл бұрын
Everyone should do whatever they want to do.
5 Common React Beginner Problems 2018
13:41
Syntax
Рет қаралды 69 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Sentence Transformers Lab - GenAI Essentials
8:39
ExamPro
Рет қаралды 17
10 React Hooks Explained // Plus Build your own from Scratch
13:15
Fireship
Рет қаралды 1,4 МЛН
View Transitions Are More Powerful Than You Think
6:11
Syntax
Рет қаралды 5 М.
Can you Learn React in a Day?
4:48
Stefan Mischook
Рет қаралды 8 М.
How I became a React developer (not what you expect)
11:23
Cosden Solutions
Рет қаралды 7 М.
What does larger scale software development look like?
24:15
Web Dev Cody
Рет қаралды 1,4 МЛН
Goodbye Array .reduce
3:55
Syntax
Рет қаралды 15 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
React Tutorial for Beginners
1:20:04
Programming with Mosh
Рет қаралды 3,6 МЛН