How to Improve Performance in React with Code Splitting

  Рет қаралды 211,668

PedroTech

PedroTech

Күн бұрын

Пікірлер: 190
@arn4v_
@arn4v_ 2 жыл бұрын
You don't have to export default for dynamic import() to work. You can instead do import('./CreatePort').then(module => module.CreatePost)
@IdandushHen
@IdandushHen 2 жыл бұрын
you actually have to return object with default import('./CreatePort').then(module => ({default: module.CreatePost})) - like this
@KevinArellano
@KevinArellano Жыл бұрын
@@IdandushHen you don't have to import/export anything, just have 1 file with 1 line of code and boom!
@davidchavarriamendez9091
@davidchavarriamendez9091 Жыл бұрын
@@KevinArellano So what's the correct method?
@KevinArellano
@KevinArellano Жыл бұрын
@@davidchavarriamendez9091 The correct method is up to your case and your boss's case. Can't really choose a "correct" methods when you can do it any way and it works. Now the correct way in my opinion is functionless/serverless architect. Anywhere where microservices can come in and pick up the slack. I absolutely hate when there's a module that either does everything or doesn't do anything at all. Also monoliths are a big no no.
@leandrogtabak
@leandrogtabak Жыл бұрын
@@jameswatadza8962 I don't even know why these people see videos that seem to be so below their level. They just come here to show themselves
@torstenmirow
@torstenmirow 2 жыл бұрын
Actually it's easy possible to use named exports instead of default exports. Import function is simply an promise. lazy(()=> import('component/login').then(comp => comp.login)) So no need to change the way you export functions.
@CarolinaNT
@CarolinaNT 2 жыл бұрын
how i leaned so much in a 10 minutes video is out of this world. Thanks Pedro, you're awesome
@ramananr3529
@ramananr3529 Жыл бұрын
Hey Thanks Man!!! Currently I am working on a project where performance is crucial. I am glad I came across this video and applied it on my project. Really helpful content, Have a great day.
@tunacant9106
@tunacant9106 Жыл бұрын
What is the result like?! I'm so curious, how much performance increase do you see? I'm really new to optimising and making it more faster.
@rahulkhatri8304
@rahulkhatri8304 2 жыл бұрын
This is definitely increase your website performance. I used next/dynamic to import components.
@henrynovoalondono2885
@henrynovoalondono2885 2 жыл бұрын
Absolutely love these small 10 minute videos. To the point, and learned a whole lot. Thanks
@shinobi_coder88
@shinobi_coder88 Жыл бұрын
Hope you stay healthy as always and keep making these micro-learning videos, it literally helps us to cultivate out mindset of "An Expert is a Beginner who stays actively curious and never quits". I like the way you do like, instead of making one long hours big project tutorial, you instead guide us to the basic concepts based on most demanded frontend trends like Performance Optimization and React Hook Form the simplified way. Bravo!!
@cutieshakira
@cutieshakira 2 жыл бұрын
I didn't know about this concept, thanks for this! also your editing has gotten super clean!
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Happy u liked it! Im re-investing into quality :)
@eshw23
@eshw23 2 жыл бұрын
Yo Pedro amazing video as usual. Good to see your still helping us learn to code while your a software engineer at Twitch!
@michaelantoni8323
@michaelantoni8323 2 жыл бұрын
Great performance optimizations, hope you do this kind of videos more.
@masj7786
@masj7786 2 жыл бұрын
I think I've learned from you in a couple of hours more than all these pointless Udemy 40+ hour courses
@MasayaShida
@MasayaShida 2 жыл бұрын
I have a mediun sized frontend project and this really helps. Thank you
@jonathanorrego6199
@jonathanorrego6199 Жыл бұрын
Gracias Pedro! nuevo skill desbloqueado!
@naveenau143
@naveenau143 Жыл бұрын
this is just point to point explanation. Loved it
@devmaheremad7360
@devmaheremad7360 Жыл бұрын
Ohh, Pedro thanks for sharing this with us thank you so much I love that features, please we need a playlist from things like this, thank you again!!!!!
@Aakashiyana
@Aakashiyana Жыл бұрын
Very well explained in a practical manner
@anton9410
@anton9410 2 жыл бұрын
Great information, thank you for posting this video.
@Abhisumant03
@Abhisumant03 2 жыл бұрын
New react course was damn good 😊😊
@enriccogemha858
@enriccogemha858 2 жыл бұрын
Great vid! I recognized the Brazilian accent as the it started playing 😆 Keep up the good work!
@maxplank1780
@maxplank1780 2 жыл бұрын
What is the end value of performance you won? Have you calculated it? Or it's just fine thoughts that you read somewhere?
@jesielpalacios
@jesielpalacios 2 жыл бұрын
6:35 Actually React Suspense has been used with the same regularity throughout all versions of it's for as long as the hook exists, but it's ok :)
@marvinfok65
@marvinfok65 6 ай бұрын
Simply & straightforward! Love the explanation!
@rahullingan2119
@rahullingan2119 Жыл бұрын
Simple and straightforward explanation! excellent work👏
@antoniobasilio319
@antoniobasilio319 2 жыл бұрын
você é incrível! Merece todo o sucesso do mundo!
@ronaldomaia
@ronaldomaia 4 ай бұрын
Pedro, seu ingles esta bem fluente! E o seu conteudo e bem apresentado! Parabens!
@andrewaghoghovwia1948
@andrewaghoghovwia1948 2 жыл бұрын
Hi Pedro..thanks for the invaluable resource. Please can you do a video on design patterns with examples. Thanks
@greimilnunez5179
@greimilnunez5179 2 жыл бұрын
Dude your content is amazing, the way that u explain things is really interesting.
@aldotube88
@aldotube88 2 жыл бұрын
Nice video, would have been good if you had the code linked in the description also though
@ZubairKhan-mb6rd
@ZubairKhan-mb6rd 2 жыл бұрын
Good information on optimisation of a react app.
@softwaredeveloper2897
@softwaredeveloper2897 2 жыл бұрын
I have always wondered how to implement this🤩. Always learning new things from you.
@priscillasilva6510
@priscillasilva6510 2 жыл бұрын
Thank you so much for this video☺You explained it so well
@badytouray294
@badytouray294 Жыл бұрын
Love this video man :-) well done with the simple explanation
@brilliantatosam
@brilliantatosam 2 жыл бұрын
Hey man, I watched this video earlier and loved the concept of lazy loading. I am currently implementing it into my current project and am here to ask if lazy loading caches loaded components. Thanks, man.
@Thanveershah
@Thanveershah 2 жыл бұрын
Jeez the quality ✔✔, What mic do you use?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Thank you
@jesielpalacios
@jesielpalacios 2 жыл бұрын
I'd be great a React crud implementation with Redux and hooks, it's without classes, using containers, slices as well for explain as other ways or cases to use, idk, a tutorial of it without pain ❤
@priyabansal9911
@priyabansal9911 2 жыл бұрын
Please make a playlist -> how to improve
@avro-vulcan
@avro-vulcan 2 жыл бұрын
i opened a tab in my browser one year ago....on this topic....obviously i lose it among all the hundreds opened tabs 😂. i finally completed my react education...10x
@tan2cang93
@tan2cang93 2 жыл бұрын
many thanks for your sharing. I have applied react lazy in my project. Howerver, there are so many named export components in project (~ 40-50 files), so I can not go into each Component to change export to export default. Fortunately, I found a package lazily on npm, it works the same as React lazy but will convert named export to default export.
@xesvitinho1231
@xesvitinho1231 2 жыл бұрын
Muito daora mano, manda muito na programação e no ingles tb!!1 brabo
@diegopajuelo9060
@diegopajuelo9060 2 жыл бұрын
nice man, finally i got it. Thanks.
@TruthSeeker23-m4o
@TruthSeeker23-m4o Жыл бұрын
what theme are you using Pedro nice color combination
@rahulkulkarni9653
@rahulkulkarni9653 2 жыл бұрын
Please make more videos on how to improve the performance of react application
@dandantin
@dandantin 2 жыл бұрын
Excellent Video. Pedro, where are you from?
@ayushnigam9424
@ayushnigam9424 4 ай бұрын
That was amazing, thanks a bunch!!
@wylakers1250
@wylakers1250 2 жыл бұрын
thanks for the vid. I was wondering what theme do you use? Thanks
@baotruong5775
@baotruong5775 2 жыл бұрын
Thank you from the bottom of my heart!
@bekiteshome4670
@bekiteshome4670 Жыл бұрын
As always brother didn't let us down!
@danhloc112
@danhloc112 2 жыл бұрын
It's very useful, thank you so much
@pauloluguenda8397
@pauloluguenda8397 6 ай бұрын
Great content bro, thank you !
@TheMrtastee
@TheMrtastee 2 жыл бұрын
great video!, is there a way to start loading in the background a lazy component after our normal component renders but before we actually requires the lazy ones?.
@mahammadmansurali7442
@mahammadmansurali7442 2 жыл бұрын
Can you also make a video on , how to improve performance in Nextjs..please
@shubhamdharpure8586
@shubhamdharpure8586 Жыл бұрын
Which theme you are using in this video
@EricOnYouTube
@EricOnYouTube Жыл бұрын
Pedro, do you have a tutorial on how to auth with Google and then register with an express API app? Thanks.
@AlamAmplified
@AlamAmplified 2 жыл бұрын
This video explains really well why you should choose angular over react.. 😂😂😂
@thecyberhobbit
@thecyberhobbit 2 жыл бұрын
in your example you wrapped the entire Routes with the Suspense... what if like you said you want to only lazy load SOME of those routes... now with the entire Routes block is in the Suspense would that force everything to Lazy load?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
The only routes that will lazy load are the ones that you import using the Lazy method. Although they are inside of the suspense, it will only lazy load if you import with the lazy function
@thecyberhobbit
@thecyberhobbit 2 жыл бұрын
@@PedroTechnologies !!! Nice makes sense thanks for the reply!
@sajidhssi3445
@sajidhssi3445 2 жыл бұрын
@Ajkl Ajkl watch his video from the start and try to understand the the explanation of the purpose of lazy loading. He explained the purpose properly.
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd 4 ай бұрын
Thank you so much pedro
@yusufs_solos
@yusufs_solos 2 жыл бұрын
Amazing explanation thanks man
@tadzyla
@tadzyla 2 жыл бұрын
Hi Pedro, thank you for sharing tips. I just want to clarify if this can be achieved as well with ? Which is rendering exact route
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
Great Video bro... helps a lot.
@TheRavageFang
@TheRavageFang 2 жыл бұрын
Just don't forget to add error handling in case on poor network lazy loading fails.
@xxvsvitorxx
@xxvsvitorxx 2 жыл бұрын
Ótimo video! Poderia fazer um vídeo falando sobre o novo use hook e como isso impactará no React query?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Vou fazer!
@cristhiancunha
@cristhiancunha 2 жыл бұрын
@@PedroTechnologies só vim perceber que era br quando vi os comentários, ótima dicção e ótimo conteúdo, me lembrou bastante a forma como o conteúdo é gerenciado (talvez por debaixo dos panos não tenha nada a ver) pelas páginas agora no Nextjs 13.
@sillasbernardodev
@sillasbernardodev Жыл бұрын
Nice explanation
@Vedant-M
@Vedant-M 2 жыл бұрын
Watching Pedro's videos never disappoints. Keep it up 👍🏼👍🏼
@Goku-zu3rk
@Goku-zu3rk 2 жыл бұрын
What are those curly braces, that appeared after you moved Suspense over Routes? BTW: You make very nice Quality-Content. Any ideas what you will do on 100k subs?
@ahmedazizabbassi
@ahmedazizabbassi 8 ай бұрын
Thanks! Great Job!
@Saiintss7
@Saiintss7 2 жыл бұрын
Is suspense a ready to use and stable functionnality with react ? Because it has been introduced an experimental one for years now
@ThColinPereira
@ThColinPereira 2 жыл бұрын
This is super helpful!
@russellbanares5324
@russellbanares5324 Жыл бұрын
Does this affect the app when deploying it?
@Monstermash355
@Monstermash355 2 жыл бұрын
Is suspense really recommended in a actual large scale application ? It's still experimental...
@elQueFaltaba
@elQueFaltaba 2 жыл бұрын
Question, because I can't check it right now. By wrapping Suspense around ALL the links and ALL the lazy loaded components you are forcing ALL of them to be loaded until the menu of links is shown, am I wrong?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
No, the menu of links is not lazily loaded and not inside of the Suspense wrapper. It might load first but its independent from the lazily loaded components. Im not sure if I understood the question correctly though so let me know hahaha
@elQueFaltaba
@elQueFaltaba 2 жыл бұрын
@@PedroTechnologies ok, I might have not made it clear (it's midnight here in Spain). Suspense wraps it's children and doesn't show anything other than the Loading component until ALL the children have been loaded, right?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Noo, the suspense will show the fallback if it is triggered. In the case of lazy loading, it will show the fallback whenever one of the components inside of it are loading for the first time. In the video you see that as i switch routes it will show the fallback as long as its the first time i am going to that route
@Krazness
@Krazness 2 жыл бұрын
Great vid bro. Thanks
@ayushyt918
@ayushyt918 2 жыл бұрын
Thanks Pedro
@sohrb
@sohrb 8 ай бұрын
can you lazy load components from an index file?
@XeonAlpha
@XeonAlpha 2 жыл бұрын
Probably a really stupid question but could you use this same idea to dynamically import a CSS theme to allow a user to select they’re own personalized theme.
@calltoreason
@calltoreason Жыл бұрын
How do you deal with paths that you request form the server and you display the path component in a react bundle? NOT ON A DEV SERVER!! YOU BUILD THE PROJECT AND SERVE IT USING EXPRESS OR WHATEVER. How do you manage that?
@davidsyengo1893
@davidsyengo1893 2 жыл бұрын
Top notch as usual
@stressed-ashen-cat
@stressed-ashen-cat 2 жыл бұрын
You can also code split packages using react loadable.
@PurexXD
@PurexXD 2 жыл бұрын
Peidro tech sensei. Saludos desde Perú.
@Lichkuroro
@Lichkuroro 2 жыл бұрын
will this work on next js?
@oneofone_1333
@oneofone_1333 2 жыл бұрын
Yo Pedro love your content always, huge inspiration. Quick question, is it normal that am having more fun and actually building stuff in react js and not vanilla js? As soon as i learned the basic in vanilla js, i moved on to react and no am a bit worried that i didnt spend enough time in learning everthing in JS and building projects. Hope it makes what i just wrote😂. Greetings from Switzerland
@golf-and-surf
@golf-and-surf 2 жыл бұрын
Why do i blink when i route between pages after adding lazy load?
@RamonBalthazar
@RamonBalthazar 2 жыл бұрын
Parabéns mano, muito bom o vídeo 👏
@jaganvichu
@jaganvichu Жыл бұрын
Same problem on my project but I used redux thunk and api calling whenever other pages openings.. so api taking some time for the response.
@MrSundaayy
@MrSundaayy 2 жыл бұрын
Thank you bro!
@raselhossain8855
@raselhossain8855 Жыл бұрын
Can we import npm package with react lazy loading?
@lilizok4
@lilizok4 2 жыл бұрын
awesome video !!
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Obrigado!!
@eduardohernandezsoto785
@eduardohernandezsoto785 Жыл бұрын
I have problem with tailwind css, it's not show css implemented when use lazy
@jpcc1223
@jpcc1223 2 жыл бұрын
Ótimo conteúdo, obrigado!
@heitortessaro5612
@heitortessaro5612 Жыл бұрын
Great content, congrats
@wpxpert98
@wpxpert98 2 жыл бұрын
Thank you
@juliandev2421
@juliandev2421 2 жыл бұрын
suspense in nextjs?
@jimzkuy
@jimzkuy 2 жыл бұрын
Isn't that the same as what next.js do?
@clickbaitpolice9792
@clickbaitpolice9792 2 жыл бұрын
Please 2 questions. 1) at 6:45 your code just automatically tabbed itself. How? 2) your tab indents are smaller than mine. How?
@Tiagocf2
@Tiagocf2 2 жыл бұрын
These are just vscode settings 1) you can configure it to auto-format the code after you save 2) his indents are configured to be 2 spaces instead of 1 tab
@Untouchable5461
@Untouchable5461 2 жыл бұрын
whats your theme font for vscode?
@softwaredeveloper2897
@softwaredeveloper2897 2 жыл бұрын
A quick question. So can one implement code splitting together with the context hook for state management and also use react query at the same time or is that too for performance optimization?
@rafaelarantes4804
@rafaelarantes4804 2 жыл бұрын
I think you are mixing some concepts up. You can have a shared state manager like Context while keeping react-query handling your API calls. You just need to be careful not to mix your shared component state with the react-query state.
@softwaredeveloper2897
@softwaredeveloper2897 2 жыл бұрын
@@rafaelarantes4804 Thank you for replying. "You just need to be careful not to mix your shared component state with the react-query state." Now this is where I think is messing me upl. Lets say a user logs into a system, where there's route/end point that checks if the "auth" is valid and a route/end point that they use to log in. In such a case, where should the use of both context and react-query come? Hope am making sense or maybe I am overthinking the concepts.
@rafaelarantes4804
@rafaelarantes4804 2 жыл бұрын
@@softwaredeveloper2897 You can implement in a number of ways. I'm going to guess your are using a CSR aproach. You can trigger both of your calls using a mutation when you login. Either, changing some local state that is a dependency of your useQuery or refetching it using the imperative property refetch that you can destructure from useQuery. Idealy, this component should be a wrapper over , that you can use as a component.
@softwaredeveloper2897
@softwaredeveloper2897 2 жыл бұрын
@@rafaelarantes4804 Wow!! thanks a ton💪. It's like you were reading through my code. I really appreciate you taking your time to help. It means a lot. How can I reach out incase of anything? Regards
@NooblantisDistrict
@NooblantisDistrict 2 жыл бұрын
not applicable to next js right?
@nabinsaud4688
@nabinsaud4688 2 жыл бұрын
I saw React router documentation v6.4 there is not available old style of doing
@bofevitaminado
@bofevitaminado 2 жыл бұрын
Brabo! Adoro esse canal
@bhumit070
@bhumit070 2 жыл бұрын
so it does not work with named exports ?
@RonnieryBorges
@RonnieryBorges 2 жыл бұрын
Mano seu Inglês está brabo congratz.
How to Make Your React App Safer
13:29
PedroTech
Рет қаралды 41 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 391 М.
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 39 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 83 МЛН
React Hooks Course - All React Hooks Explained
1:26:21
PedroTech
Рет қаралды 1,1 МЛН
Code Splitting in React JS - Lazy Loading Performance Optimization
16:10
This is the Only Right Way to Write React clean-code - SOLID
18:23
3 Ways to Make React App FASTER
14:43
Piyush Garg
Рет қаралды 46 М.
8 React Js performance optimization techniques YOU HAVE TO KNOW!
11:23
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 503 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 792 М.