I'llexplainserviceworkers, aswe, uh, getsit a particularpoint.
Removethis, um, andwhy I generallyliketodo I justinsteadofcallingreactonheredirectly, I liketojustremovethatandjustsaid, Givemerenderandthenwecangetridofitseemedasthoughthisisnolonger a defaultimport.
We'regonnaneed a serviceisfollowedup, buttheFBIcalls a stallsfolderforourstylesUtilitiesfolder, whichwouldbasicallyjusthousestuffedupiskindofmiscellaneous.
Saywegotthisoneheretonineor 662655 Wewanttogoaheadanditsays, forexample, a storyliveshere.
Soifwechangethisitemtwo.
Yes, youare.
L you'llgetallthisthere, andthat's prettymuchallwe'regonnabedoing.
Sowe'regoingtodotoFBIcalls.
Well, tworoutes.
Wegotthecranetoservicecontentroots.
I wasgoingtocallinthisFBIfatherstoriesbecauseweonlyneedtocallthisonethesetpiece I wroteoncebecauseweonlyneedallthenewstoryideas, thiscase, It's topstories.
ButyoucandothatnewstoriesandwithalltheideasandmakeFBIcallstowiththeseideastogetthestorysothatyet I wasprettymuchit.
Really, Um, I guesswhatweneedtodonextisah, have a lookwhenyoucreatenewtubinherebiggerandwhat's gonnadoyoungartAxios.
Andactually, Rossiis a nicelittlepackage.
It's notreactspecific, butit's a nicepackagethatallowsustodoFBIcalls.
Stuffalwaysgoeswrong, and I thinkit's besttokeepsome.
Whatofitintutorial.
Sosetstoryideas, too.
Hello.
Sothereweare.
Wegothellothere.
Oh, yeah.
Sowhathappensif I wantedtochangethis?
Soif I justgetridofthisand I'llstillyouknowAh, printitall.
Whatdoyouthinkthat's gonnabe?
It's justgonnabeanemptyyourair.
Andyoucansomeonelikestringif I thisAndnowwearesometimesera, sothatallowsherselfsomesanitycheck.
Soif I justbringbackinimport, getstoryideasfromserviceishowcanuseFBIandthensay, forexample, um, I wanttocallthismethodnowthatwe'veputtogetherwe'vedonealltheworkinhere.
I wasgonnacallthisnowso I canjustsimplybecauseit's a bitisbeingemployeduphere.
I couldjustsaygetstoryideaslikesir, butwhatwegottadoOops.
PuttingnightsideTheaWell, what's that?
Well, thatisjustyet, but I'lltellyouin a second, let's have a look.
BubbleLordcannotfindservice's can't ResultsService's Let's take a look.
Sowe'verunintothesameerrorasbefore, so I'm thinkingthatis, Well, it's notverydescriptive, isit?
So I don't knowifthisis a caseofletmerestartthisstartin.
It's takingitstime.
That's fine.
Soitworks.
I don't knowwhattheissuewasthere, soYeah, we'vegotthestory I d s.
Andif I letmelockthisout, Um, so I wanttomake a fewimportantnotesaboutwhat's goingon.
They'resoyousee, hesayspromise.
But, youknow, I thoughtitwasreturningmeMydata.
Yousee, thestatusisresolved, thevalue, andwe'vegot a bunchofdeadassignedtherefromtheFBIsays 500 ideasandaging.
Seethere.
Butwhy's theHopman?
Well, youseehowwe'vestoppedthisairstinkonhere.
SoanyfunctionthatyoustickinEssencan't willalwaysreturn a promise.
Sonowwhatwehavetodo, wehavetogobackupdotJs.
And, sir, wecan't justcallthisdirectlythat, likewejustdidthen, like a regularfunction.
Wehavesaid, Okay, oncethedebtisthere.
Yousee, I wasgivingmetheseoptions.
Soit's saying a touchescoalboxfortheresolutionandorrejectionofthepromise.
So I'm going, Okay.
GogetmethoseID's andthenreturnmetheresult, whichwillbe a promisewiththedareheldinthere.
Andwehavetoresolvethatpromisesowecansayandtoresultthatwecanjustsaidthenandbysayingthenonthisparticularreturnpromiseherebecauseit's a synchronous, remember, it's asynchronousandthebignoislike I justmentioned.
Italwaysreturns a promise.
SoyousayGetstoryideas.
Don't.
Thenwegotset.
Okay, givemethedayandthiscouldbeanything I couldsaylemons.
SoonceyouhelpedthelemonsgoaheadondhesetstoryID's onbycallingsetstoryideashere, we'regonnareplacethisemptyinitialized, a rarewithour 500 storyideas.
Howcoolisout.
Solet's take a look.
Setstoryideaswithlemonslike a set.
Youcancallanythingorchange, obviously.
But, youknow, bornwhat's goingonhere?
Object.
Notgreat.
That's perfect.
Sowhenyoudoseethis, objectsarenotvalidasreact.
Children.
Weknowit's well.
I knowit's words, and I'llshowyouwhyin a secondandwhythathappensbecauseyouhavetogetusedtoreadingtheseerrorsborn.
Youseethat.
Soyouinitializeit.
Youinitializeitquick.
It's anemptyyourear, andthenitreturns.
Youallthisthere?
Butyouhavesomeissueshere, right?
Sothisissaying, isgivingmeallthedirtaboutfromaccessand I don't wantno.
Because, youknow, thisis, youknow, it's a networkcalledWell, there's noreasontouse a nestingherebecausewhatwe'redoinghereisthisisreturningme a promise.
Soit's stillsolemn.
Thislittle Q calledtheMicrotaskyou.
Andonce I resolvedthatit's gonnagetpoppedoffthat Q andgetwhippedaroundtheevent.
Ah, if I putinthe, umlet's say, forexample, wehadthevariableslikestoryideasofdeadanditjustbestitwastrueorfalse.
Wecouldkeep a watchonthisso I couldputstoryideas, updateinhere, andbasicallyusedeffectwillwatchforthistochange.
Soif I passed, maybe a settimealsosettimeout, which I'd neverdo.
Butif I every 10 seconds, eventhoughthisisneveraccurateintermsofthereadingofftheseconds, it's bestsaying, Dothisfor a minimumoffthat I'm not a seconds.
Soifyouhavetwofilesandmillisecondsitsaying, dothisfor a minimumof 2000 milliseconds.
Butlet's say, forexample, inhereevery 2000 milliseconds, I, youknow, didstoryideasoftheirladycourtTrue.
Umandthen I eventuallykeptswitchingbetweentrueandfalseissues.
Effectwillseethat, andthenitwillbelikeOkay, well, thisstory I d s updatedhaschanged.
I needtorerunthisagainwhenitrerunsthatitwoulddorearenderand, youknow, potentiallycouldhavenewstoryideassowecouldgetnewstoriesso I couldhave a livefeedofnewstories.
Soit's putupbacktonormalandyou'llseethatpatterneverywhereinreality, isbasicallyserveyoufromhavingtopropstopstory i d whichisAh, quitelongwindowsondhestory I d.
Sonowwhatwewanttodoiswewanttomake a callandseenasthoughwe'vealreadybuiltthisgetsstory, we'rejustgonnaprettymuchfollowthesamemethodWelldoneherewherewe'redoingandgetstoryideasandthenplaceintostoryideas.
Thestory i d whichisbasicallyjustthisproblemgetspasseddownandwe'llresolvethisyearsynchronousfunctionandsaid, uhandsometimesonthisFBI, I'veseenthatthedotcomwithurels.
So I'm justgoingtosayOK, oncewe'vegotthat, uh, whatisbeingresolved?
And, youknow, you'vegotthedeerinhere.
I'm notjustgoingtoreturnit.
I'm goingtosay I'm donetomakesurethatwehave a deadgirlandifwedohave a debtthatyouareallsetstorytodare, andthat's prettymuchitandyoudon't havetowatchfor a storyidea.
Changingsaidthiscasewasgoingtodisablethat, yes, laterule, becausethefactofthematteris, hereisthis'llstory I d evenevenknowit's ah, it's kindofcomponentbestwhereweonlyneeditonce.