React Router in Depth #6 - Loaders

  Рет қаралды 62,307

Net Ninja

Net Ninja

Күн бұрын

Пікірлер: 81
@donnmichaelcleofe7132
@donnmichaelcleofe7132 8 ай бұрын
I really appreciate when the tutorials are up to date. Pls keep the good job
@jerrerock
@jerrerock 5 ай бұрын
I am following a course on CodecAdemy but for many parts I am also watching your tutorials which are explaining it a lot better!
@m_miko
@m_miko 2 жыл бұрын
You're the first guy I recommend to anyone I know when we come to programming staff, I question I this you can return your loader with a defer like return defer({ value: somethingHere }); can you do a video on that too please.
@stefanmasic1287
@stefanmasic1287 Жыл бұрын
I'm just enjoying and learning. Super perfect. Thanks 1.000.000 times.
@maskman4821
@maskman4821 2 жыл бұрын
Wow, React has evolved, the loader function is one of the feature Sveltekit provides, it fetches data and render right before component mounted, this way we get better user experience because we don't need a loader indication and user won't see empty content. I think React is pushed to Server side render way, all these popular frontend frameworks has SSR capability right now in order to survive, because meta-frameworks such as Sveltekit, Next, Nuxt, Remix are taking over, it is good to know we can do this with React 😘
@ssumit196
@ssumit196 2 жыл бұрын
but it doesn't provide cache and other features like react-query and swr right?
@lenvonahom
@lenvonahom Жыл бұрын
you are just master of all code i got all i need for the semester in just you 1 series of video thanks a lot your are really being helpful
@emuemhonjieonosereme2495
@emuemhonjieonosereme2495 Жыл бұрын
Sir for this loader async function we use await but there is no try catch block.. What if the route localhost:4000/careers cannot be found ie it throws an error, will the react router automatically render the error element?
@Michael.design
@Michael.design 2 ай бұрын
Perfectly explained❤ Better than the paid course I’m following😂
@NetNinja
@NetNinja 2 ай бұрын
Thanks Michael! :) more at NetNinja.dev
@ggrlmon
@ggrlmon Жыл бұрын
I've been following your other videos and it really helped me have a better understanding of how react router works. Regrading loaders I think you missed one fundamental concept here, which is the wait time. Since you're loading your data from a static file there's no wait time. Using this loader approach when calling actual api's there would be a delay before the page renders. With the useeffect you can handle that delay by adding a spinner or something, informing the user that the page is loading. Is there a way to do that with the loader?
@aymanechaaba
@aymanechaaba Жыл бұрын
use Suspense or state from useNavigation hook provided by React Router. let me know if this helped
@masterwayne9790
@masterwayne9790 Жыл бұрын
@@aymanechaaba Suspense component might help with his case as you mentioned
@AmitKumar-cp6mx
@AmitKumar-cp6mx Жыл бұрын
I have a couple of questions? 1) What if data fetching take some time?, how can we add spinner ? 2) how to use data in other pages? Cuz fetching data everytime is a bad practice. (I think if we dispatch an action or setState in the rendered component then it can work otherwise we can't use hooks and rtk outside the react component) 3.Can useLoader completely replace useEffect in data fetching?
@shineLouisShine
@shineLouisShine Жыл бұрын
I wish someone who knows the answers would have respond to you... 🧐
@ITLearning-ug2hp
@ITLearning-ug2hp 3 ай бұрын
I have the same question as you
@nickwoodward819
@nickwoodward819 Жыл бұрын
is there any way to have reduxTK deal with the request? like maybe dispatching an action from within careersLoaded? (~ @3:30) would that work?
@orionsquare
@orionsquare Жыл бұрын
@3:41 does not work for me. Put up a comment but was deleted?
@Spyder22dz
@Spyder22dz 5 ай бұрын
thanks for the tutorial , now my search bar works just fine with this loader method
@annametel9638
@annametel9638 Жыл бұрын
Thank you You are my favourit teacher!💓
@NetNinja
@NetNinja Жыл бұрын
Wow, thank you! :) that means a lot
@1910X3
@1910X3 7 ай бұрын
Very nice tutorial about "React Router"! Hope you can make a series tutorials about "Remix Run" of React!
@dennisogbonnaya5923
@dennisogbonnaya5923 2 жыл бұрын
How do you handle server errors with the useLoder hook?
@a13519
@a13519 10 ай бұрын
Your are the best on KZbin
@adscity-25
@adscity-25 5 ай бұрын
That's a really great lesson course and easy to understand, good job Sir 🤩🤩. It'd be a salvation if you could make a tutotial on how to host a React App, as you are using react-router-dom hook. I am struggling on something called Client Side Rendering & Server Side Rendering (which returns a 404 page not found, in my case). Would appreciate, Sir ✨✨
@pjc825
@pjc825 2 жыл бұрын
Can't wait for you to do a SvelteKit 1.0 course, now that its officially released 😀👍
@nishantnimish7825
@nishantnimish7825 Жыл бұрын
Is loader worth using over useeffect except the memory it saves us?
@muhammedrashid3957
@muhammedrashid3957 2 жыл бұрын
is loader replaces useEffect hooks? I don't understand when to use loader function exactly can anyone explain?
@2pac2pac2pac
@2pac2pac2pac 8 ай бұрын
the end point created automatically but how it got the /careers from where it got this
@codewithluq
@codewithluq Жыл бұрын
Does the loader function make useState and useEffect ways of fetching data sort of obsolete??
@Tussu17
@Tussu17 10 ай бұрын
I think the same!
@hervinsonsamson1531
@hervinsonsamson1531 Жыл бұрын
Is this a good idea to put my authentication in the loader fn?
@muhammadrifqy24
@muhammadrifqy24 Жыл бұрын
I am trying to use useLoaderData in the other page, but the result is being read as 'undefined'. Does this mean that useLoaderData can be used only in the route component in which loader has been used. If yes, then how can I use the result returned in the other page? 🙏
@RustemmKh
@RustemmKh Жыл бұрын
useFetcher()
@willysnowman
@willysnowman Жыл бұрын
I watched the whole tutorial. Thank you!! Loaders seem to work well for /componentA/componentB/:id. My data, however, is dynamic so I cannot point to :id as the id may change as the data changes. So my path ended up /loader where useEffect loads the data into session memory then redirects to /componentA which reads the data from session memory. I could also useContext, but session memory works for now. Just pointing this out for others since it took me a while to realize it. Once you redirect all the state and params are gone!
@Dakun
@Dakun 9 ай бұрын
Actual information starts at 4:34
@517nickyj
@517nickyj 2 жыл бұрын
Can you use the useLoaderData hook in subroutes and treat it as a sort of context for all child routes?
@dennisgiovanniaguirreherna9361
@dennisgiovanniaguirreherna9361 2 жыл бұрын
I think useLoaderData should work with that, is also included with React router 6
@rumble1925
@rumble1925 5 ай бұрын
userouteloaderdata(routeId) does this
@taofeekiyanda3050
@taofeekiyanda3050 2 жыл бұрын
Amazing 😍. Just at the right time
@NetNinja
@NetNinja 2 жыл бұрын
Hope it's helpful Taofeek!
@onigbindedavid6630
@onigbindedavid6630 5 ай бұрын
Please how do I use ds for firebase authentication since i can't use hooks with ds
@iganic7574
@iganic7574 Жыл бұрын
but what about error? what if error generate while making api req?
@RoyaLearns
@RoyaLearns 2 жыл бұрын
Hi I did all the steps but I'm getting this error : Failed to fetch Failed to load resource: net::ERR_CONNECTION_REFUSED What should I do?
@yhuukee7053
@yhuukee7053 2 жыл бұрын
Loader can be used with custom hook?
@maskman4821
@maskman4821 2 жыл бұрын
Nope, it can't, it fetches data and render before dom mounted, it works kind of like sever side render.
@yhuukee7053
@yhuukee7053 2 жыл бұрын
@@maskman4821 ok, thank you!
@mm6710
@mm6710 2 жыл бұрын
i tried to use it with ContextAPI but i got an error saying ( i can't use 'useLoaderData' outside of a route ). suks but understandable
@siralone3646
@siralone3646 2 жыл бұрын
Does anyone know how should I combine a React Router and RTK Query? RTK Query creates a Hook, should I use that hook on my loader function? Thx
@dapolcio3405
@dapolcio3405 Жыл бұрын
Isn't it a bad practice to fetch data from server every time we go to career page? Isn't it better to fetch it once with useEffect hook?
@andrewtran9870
@andrewtran9870 Жыл бұрын
Complete beginner here, but if you used useEffect to call the API, wouldn't it still need to call the API and fetch data from the server every time the career page is accessed?
@rumble1925
@rumble1925 5 ай бұрын
No don’t optimise prematurely
@kelsey_roy
@kelsey_roy Жыл бұрын
Alternatively, you could put this in `your package.json` scripts section: `"start-db": "npx json-server --watch data/db.json --port 4000"` . To call it, just do: `npm run start-db`
@fariadworld446
@fariadworld446 Жыл бұрын
Why are you using Loaders to fetch data and not useEffect?
@GhanayemOmar
@GhanayemOmar Жыл бұрын
how can i pass data to the loader fun?
@suzunome47
@suzunome47 Жыл бұрын
Does anyone know how to use useContext in a loader function? I need to access some data in my global context but apparently you can't use hooks outside of a React component.
@vasylmashkarynec7078
@vasylmashkarynec7078 Жыл бұрын
It's impossible for the moment, or at least it's not suppose to be used there, router developers stated that loaders and actions was introduced in order to decouple fetching data and rendering, however there is voting to introduce this functionality like element: ... loader: ... context: ...
@adiii41
@adiii41 11 ай бұрын
It would be much nicer if you could put any hooks inside loader. Now for example im wondering how the heck use lodaing screen while loader is fetching data :D
@Jamie-qz7vm
@Jamie-qz7vm Жыл бұрын
There is no outlet component specified .
@ВіталійБілоус-э2в
@ВіталійБілоус-э2в Жыл бұрын
Try to add some latency and you will be wondered with this approach
@GethushanRavichandran
@GethushanRavichandran 2 жыл бұрын
Please create a Playlist about "Creating E-Commerce Website using Strapi , MongoDB, React , and Stripe"
@towatch
@towatch 2 жыл бұрын
♥️♥️✌🏻
@mohamedyoussef8835
@mohamedyoussef8835 2 жыл бұрын
Awesome video +++++++++++ 😀
@michalnowak2181
@michalnowak2181 Жыл бұрын
thx
@michaelkurzewski2937
@michaelkurzewski2937 2 жыл бұрын
Elooo. I think we could abandon react router, and turn our attention to tanstack.
@pen.is.leaking
@pen.is.leaking Жыл бұрын
so good
@souviknag
@souviknag 10 ай бұрын
is this possible to call multiple loaders, passing the redux store? ...... { path: "overview", element: , loader: [viewLoader(store), viewWorkLoader(store)], } .......
@flowerofash4439
@flowerofash4439 Жыл бұрын
I am stil not sure why that hook is made, we can just make the same behaviour with useEffect. also what if it is used in real world where upload and download speed is a thing, there is no mentioned way to tell the user that "the app is not frozen but we are downloading something", while using useEffect everybody know how to handle it.
@niraz9130
@niraz9130 7 ай бұрын
9:30
@lovelynduru-magnus3233
@lovelynduru-magnus3233 Жыл бұрын
I'm getting "assignment to undeclared variable res" when i click on the careers link. Am i missing something? @NetNinja
@ReadingNotAllowed
@ReadingNotAllowed 2 жыл бұрын
Anyone else getting """ Unhandled Thrown Error! - NetworkError when attempting to fetch resource. """ when entering localhost:3000/careers ?
@flyflor599
@flyflor599 2 жыл бұрын
powershell Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
@mambaa11
@mambaa11 Жыл бұрын
@@flyflor599 for some reason it does not work for me. it just says command not found
@chasemorin1843
@chasemorin1843 Жыл бұрын
getting same error output to browser, no errors in the terminal
@chasemorin1843
@chasemorin1843 Жыл бұрын
add "proxy": "localhost:4000/" in your package.json file. In your careers loader function use a relative path in your fetch command ('/careers') is stead of the whole domain path.
@hahahahm6003
@hahahahm6003 Жыл бұрын
use npx before the command he typed
React Router in Depth #7 - Route Parameters
10:01
Net Ninja
Рет қаралды 41 М.
React Router - Complete Tutorial
23:53
Cosden Solutions
Рет қаралды 160 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 505 М.
Предзагрузка данных через роутинг
24:48
Михаил Непомнящий
Рет қаралды 30 М.
React Router 6 - Full Course
9:44:43
freeCodeCamp.org
Рет қаралды 258 М.
React Router in Depth #4 - Nested Routes & Layouts
11:22
Net Ninja
Рет қаралды 79 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 497 М.
Loading data in React Router using the new useLoaderData hook
19:42
React Routing and Context (useContextOutlet) - Best Way🔥
13:52
Studytonight with Abhishek
Рет қаралды 6 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН