Andtoday I'm goingtobringyounotsomeboringtodolistapplication, but a muchmorefunPokemonapplicationthatallowsyoutoseeallthedifferentPokemonpaginatedthroughthemusinghooksandallofthemodernreactfeaturesstartingnow.
Andnowifwesaythatallofourcodeisexactlyhowwewantit, just a verybarebonesapplicationthatdoesabsolutelynothing, whichisperfecttogetstartedwithinordertorunthis, wecouldjustrunNPMstartandthisisgoingtoruntheapplicationforus.
Andif I justmovethisovertotheside, thisistheapehighthatwe'regonnabeusing.
Butas I mentionedjust a littlebitearlier, thisisthe a p I thatwork.
You'regonnabeusingthispoky a p I.
Andessentially, whatitallowsustodoisQariOld, thePokemonthatareavailableasyoucanseehereifwejustgohttpspokeyap i dotcoslash a p i v toPokemon.
Weget a listofresultsdownherethathavethenameofPokemonandthegirlformuchmoredetailedinformationonthembeforeourcases.
Allwe'rereallyworriedaboutisthisnameaswellasthisnextandprevioussectionwhichallowustodopaginationinsideofherapplicationbecausebydefault, only 20 resultsarereturnedtothetime.
Sowhenwegoto a differentpage, wecancallsetPokemonandupdatethelistofPokemonthatwe'reshowinginsideofourapplicationinordertogetstartedandjustseewhatourapplicationwilllooklike.
AndwhatwecandoinsideofourreturnstatementisifweimportourPokemonlistcomponentthatwecreated, soputhimon a listfromandwhenyou'reimporting a localcomponent, youcanusedotslashtogetyourcurrentdirectory, andthenweseehere a Pokemonlistsowecanimportitjustlikethat.
Sowe'regonna d structurethepropsandinsideofherewe'rejustknowthatwe'repassingit a variablewiththenamePokemon.
Sowe'regonna d structurethatfromthepropsargumentbecauserightnowthisispropsandwehavepropsdotPokemonbeingpassedintoitsowecouldjustactuallytakethisonestepandjust d structureithere.
Soinourcase, we'regonnareturn a singledivandinsidethatifwe'regonnaputthenameofthePokemon, whichinourcaseisjustthat p variablebecauseourlistisjust a listof a raiseofnames, andthenwhenyou'reinreact, youactuallyneedtohave a keyforeverysinglethingthat's insideofanarray.
Soit's installedthatbyjusttypinginherein P m I Axiosandthat's goingtoinstalltheaccesslibraryforce, whichisgoingtoallowustomake a synchronousrequesttwoand a p I, suchasthispoky a p i.
Andso, forexample, ifwewanttogetsomethingfromthe a p I weaken, justsayAxiosdotgetandwewanttopassitthegirlwe'regonnabeusing, which, inourcase, wecanseeoverhere.
AreyouEarl?
Isthishttpsslashlastpokeyap i dotcoslashFBIsuchbetoslashPokemon.
Soifwejustpastethisinsideofhere, thisisgoingtomake a fetchrequest, andit's goingtoreturnus a promisesowecandoiswecouldjustdo a dotthenonthatpromise.
Andthispromisehasessentiallytheresponseforourrequestasthevariablethatgetsreturnedandas a propertyandcalleddata, whichisgoingtobeallofthisJasonthatyouseeinsideofhere.
Anotherthingthatwewanttomakesurethatwedoisactuallygiveourapplication a loadingstate.
Becauserightnowwererenderapplication.
It's juststartsas a blankpage.
AndthenaftertheAP, I requestitrenderseverything.
Butto a user, itmaylooklikeoursiteisbrokenifwejustshowthem a blankpage.
Soinsteadwewanttoshowthemsometypeofloadingscreen.
Soagain, we'regonnausesomestatetosetup a loadingapplication.
Sowecansayloadingthisisjustgoingtostore a trueorfalseforifourpagesloadingandwewantsetloadingAndofcourse, we'regonnausesomestateandbydefault, we'regonnaputourapplicationinTrue.
Whathappensiftheusercallsthisuseeffectmultipletimesin a rowbeforetherequesthasfinished, you'regonnahave a raceconditionandthinkscouldoverwriteeachother.
Wewanttomakesurewecanceleveryoldrequesteverytimewemake a newrequest.
Andthegreatthingaboutuseeffectisitallowsyoutoreturn a function, andthisfunctiongetscalled.
Inourcase, it's goingtoallowustocancelourpreviousrequesteverytimewemake a newrequestandaccesshas a reallygreatwaybuiltintoitthatisgoingtoallowustodothis.
Wecanpass a secondargument, whichistheoptionsthatwewanttopasstoget.
Andithassomethingcalled a canceltokenTakesanobject, andthisobjectis a newaxisdotCanceltoken.
Andessentially, thiscanceltoken, allitdoesistake a function, andthisfunctionreturnshere.
Itleadsournextpage, andnowourpreviousbuttonshowsupbecausewehave a previouspagetogotoweaken.
Clicknext.
A fewmoretimesyoucanseeourloadingscreenisworking, andthiswillgoallthewayuntilwegettothelastpage.
There's a lotofpunkywants, soobviously I'm notgonnaclickthisbuttonallthewaytillwegettotheend.
Andthat's allittakestomake a simplereactapplication.
Ifyouenjoythisvideoandwanttolearn a tonmoreaboutreact, makesureyoucheckouttherackcourselinkedindescription.
I gooversomanyfeaturesofmodernrack, andbythetimeyou'redonewiththatcourse, you'llknoweverythingyouneedtoknowaboutreactinordertostartbuildinganyprojectyoucanthinkofSowiththatoutoftheway, Thankyouverymuchforwatchingthisvideoandhave a goodday.