Sointhistutorial, Siri's we'regoingtobecreatinganevernoteclone, andit's goingtobealmost a fullyfunctionalEvernoteclone.
There's goingtobecertainfeaturesthatwe'renotgonnabeimplementinginthistutorial, suchasusers, although I dohaveanothervideopreviousvideothat I createdwherewedogooverthat.
Soifyou'd liketolearnmoreaboutthat, thereis a linkinthedescriptionbelowforthatvideo, Siri's.
Butinthisvideo, we'rejustgonnafocusonEvernote.
We'regonnabeusingfirebase, andwe'regoingtobeusing a librarycalltoreactQuill.
So I thinkit's timeforustogoaheadanddemonstratewhatitiswe'regoingtobemakinginthisappso I cancomeoverhereandclicknewnote.
Enter a newtitles.
Callitnewnote.
I submittedtheknow, andasyoucanseeit, selectthatautomatically, andoverhereontheright, wehave a texteditorandwecaneditthetitleorjustcallitlikenewnote, too, andthen I cancomedownhere.
Youcanseeitupdatedlive, and I cangoheadingone.
Thisis a header.
Andagain, youcanseeitupdatesliveoverhere.
Andso I can, youknow, justthisissomeMaurtext, youknow, just a showthatwecanhavedifferentsizetextsandeverything.
Great.
Anothernotewouldjustsaytestlistandcomeinhereandcreate a list.
You I forthis, whichisgoingtobe a librarythatallowsustomakestylingveryeasy.
It's gonnahandle a lotofthingsthatjustincludesreactcomponentsthatwecanusethatmakesthingslookprettybydefault, essentiallysothatwecanfocussolelyonreactandnothavetoworryaboutwriting a tonofCSS.
Solet's goaheadandstart.
We'regonnasayNPMinstallatmaterialhyphen u ieslashcore.
Sogoaheadandinstallthat.
Andoncethat's done, goaheadanddoNPMinstallatmaterialhyphen u ieslashiconsandthisisgoingtogiveus a tonoficonstobeabletouse, which I thinkwe'reonlygonnabeusingtwoiconsthetrashcanfordeleteandthepencilonpaperforeditSogoaheadandwaitforthattofinish.
Okay?
Andforourtexteditorwillbeusing a reactquill, whichisanopensourcelibrary.
Sowewillsaynpminstall, react, hyphenquill, Q u i l l Goaheadandinstallthat.
I'm savingitrightnow, and I'm comingovertothereactupjusttomakesure I don't haveanyerrorsandsayshereitlookslikeyou'reusingthedevelopmentbuild a firebasedJssdk.
Sothefirstthing I I liketodois I'd liketocomeinhereanddeleteallthisdefaultstuffthatcomeswiththedefaultreactapp.
So I gointoapdotJshereandinsideofthisreturn.
Actually, I'm gonnagetridofthiswholethingandmakeit a class, sowe'llcomeinhereandsayclassapextendsreactdotcomponent.
Andnowwehave a classinsteadof a functionwhichtheclassneedstoactually, umneedstoimplementtherenderfunctionandinsideoftherenderfunction, youhavetoreturnsomeHTML.
Sofornow, I'llputin a dipthatjustsayshello, worldCool.
Sowhatthisisgoingtobewehave a D bouncefunction, whichisgoingtobehelpfulforus, becausewhat, Whenwearetypinginsideofthetexteditor, we'regoingtowanttoupdatethedatabasealive.
However, wedon't wanttosend, umwedon't wanttosendrequests.
Everyeverysingletimewetype a a letter.
We'regonnawanttowaitfortheusertostoptypingforabout a secondorso, maybetwosecondsbeforeweupdatethedatabasesothatwe'renotjustgoingcrazyonthedatabasewithallthesecallsishttpcalls, Sowe'regonnabeusing a deepbalancefunctionrighthere.
ThisisverypowerfulonSnapshotisgoingtoautomaticallygetcalledwheneverthisnote's collectionisupdatedinside a firebase.
Sowheneversomethinggetsupdatedinsideofthenotescollectionandfirebase, thefunctionthatwepassintoonsnapshotwillgetcalledandthatspecificfunctionisgoingtobepassed a anargumentautomaticallythatwe'regoingtobecallingserverupdate.
Andlet's goaheadandcreate a constantoldnotes, whichisgonnabeourarray.
Sowewanttogoaheadandsetthatequaltoserver.
UpdatedotDocksandDocksis a propertyoftheserverupdateparameter.
I'm sorry.
Doc's is a propertyoftheserverupdateobjectthat's gettingpassedintoourfunction, andwewanttomapit.
Andso, ifyou'renotsuperfamiliarwiththemapfunctioninJavascript, I'vegot a reallygoodtutorialonthat.
Goaheadandlookinthedescriptionandwatchthattutorialisveryshort, butit's got a visualrepresentationofhowmapworksinsideofJavaScript.
Andifyou'renotveryfamiliarfamiliarwiththat, I highlyrecommendyouwatchthattutorialreallyquickbecausewe'regonnabeusingit a lotinthistutorialseries.
Solet's goaheadandsayforeachdocwewanttocreate a concertcalledDataandsaidequaltodocdotdata, whichis a functionwhichgrabsthedatafromthedock, andwewant t o add a propertytoourdataobjectthatwe'recreatingcalled I D.
Sodata I d willliterallyjustbeequaltodocdot i d Andthenwe'regoingtoreturnthatSowe'llreturndatasowesuccessfullyhaveanarrayofallofthenotes, andthenwewanttogoaheadandupdateourstatesotheystopsetstateandinsideofhere.
Sowedon't haveanythinginsideofWedon't haveanynotes, sowecan't reallyseewhatthislookslikeyet, Butwhat I wanttodoisgoaheadandcreate a consoledotlogstatement, consuldotlognotesandwanttosaveitbecause I wanttoshowyouguyswhatthislookslike.
Soasyoucansee, wecomehereandwhen I gototheconsole, wehaveanemptyarray, andthat's simplybecausewedon't haveanynotesinside a firebase.
Solet's goheretoFirebaseand I wantyoutogobacktoyourdatabaseandyoucanseethistablehere.
Sowhenweadd a collection, remember, wecalledthatcollectionnotes, okay, andweclicknext.
Andwhatiscalled a testnotefromFireBase, Itwillalsohave a a body, sowe'llcallitbody, andthenthat's goingtoactuallyendupbeing a stringofHTML.
Soinhere, I'm justgonnaputan H onetaghelloworldandatclosing h onetag.
Andthenitwillalsohave a timestamp.
But I'm notgonnaworryaboutthetimestamphereinthisparticularcase, becausewe'regonnaautomaticallygeneratethattimestamp.
Soclicksave, and I canseethatwehave a notehere.
Andifyouremember, when I saidwheneverthenotescollectionisupdated, it's goingtoautomaticallycallthatonsnapshotfunctionthatwe'repassing a functionintosoLet's gobackoverhere.
Andasyoucansee, itwentaheadandactuallyranthatfunctionautomaticallysimplybecause I updatedthenotes, Uh, thenotescollection.
Soyoucanseeherenowthatwehave a title I d andbodyof a singlenotethatwejustcreatedinside a firebase.
But I wantyoutounderstandhowthisisworkingsoinsideofhere, there's goingtobe a functionthathas a bunchof, um, a bunchofclassesthataregonnabetheregoingtorepresentCSSstyleshere.
It's takingthosestylesandthenbasicallycreatinganobjectcalledclassesor a propertyandreact.
It's actuallyprops, soit's creating a propcalledclasses, andwe'regonnabeabletoaccessthoseclassesfromtheIt'lllooklikethis.
And, ofcourse, it's gonnahave a constructorherewithsuperandthentherenderfunction, which I willagaincopyfromthepreviousoneandinsteadofsidebarwillsaysidebaritem.
So I'm gonnastartwithmystyle's dotJsfileformyeditor.
Sounderundereditorhere, insideofstylesdotJs I simplypastethis.
Andasyoucansee, um, Stilesis a functionwith a, uhargumentcalledthemethat's passedintoitautomaticallybymaterialYou I whichreturnsanobjectofbasicallyCSSclassesandstyles.
Sogotothedescription, gotothesourcecodegoingtothepublicfolder, andthentheindexdothtmlfileandthenwhatyou'llseeinthesourcecodeatthetopofinsideoftheheadertagsattheverytop, you'llsee a link, Um, a linktagwith I'llshowyouexactlywhatitlookslikehere.
Thesecondthingthatwe'regonnathrowinyearisonchange, andwe'regonnahave a functioncalledthisupdatebody.
So I'm gonnaputthisstuffonitsownlinereallyquick, makeitlookclean.
Sowehavevalueandonchange.
Now, thisdotupdatebodyisgoingtobe a functionthatisgoingtobe a synchronousthat's goingtosetsomestate, andoncethestateupdates, we'regonnacallanupdatefunctionthatisgoingtodosomestuff I don't wanttotalktofarahead, solet's goaheadandimplementupdatebody.
So I'm gonnaputupdatebodydirectlyundermyreturn.
SorryonhermyrenderSococoatomyrenderfunctionandcreate a variablecalledup a bodywhichallsetto a function.
Now, thisisgonnabein a synchronousfunction.
Sogoaheadandaddyourracingkeyword, andit's goingtoaccept a value, andwe'regonnadostuffwiththatvalue.
So, like I said, we'regoingtosetsomestate, butwe'regonnawaitforthatstatetoupdate.
Sounderneathupdatebody, wewillcreate a functioncalledupdate.
Now, thisiswherethingsget a little, uh, somewhatcomplicated.
So I'm gonnadomybesttoexplainitforyou.
Sowehave a functioncalledupdateandwe'regoingtosetitequaltodebounce, andwe'regonnapass a functionintothebalance, whichisgonnabetheactualfunction.
So I'llexplainthisjust a second.
I justwanttogetthisoutoftheway.
Okay, so D balancesandourhelpers.
Soif I gotohelpers, thatJsweimported, um, weimportedthatrighthere.
So d bouncesinourhelpershere.
Andwhatwedon't wanttodoiseverysingletimethevaluechangesgotothedatabaseonfireBaseandupdateitbecausewhatthatmeansishastheuserstypingintheirtexteverysingletimetheytype a letterorcharacterare a backspaceoranythingatall.
It's goingtomakeanhttprequeststothedatabase, andthat's gonnaget a littlecrazy.
So I'm cominginhereintomytexteditor, and I'm justtypingsomestuff, typingsomestuff, typing, typing, typing.
Andnow I'm gonnastoptyping.
Okay.
Yousawthat.
I stoppedtypingfor 1.5 seconds, andthenthisfunctionappeared.
Itdidnotappear 20 timessince I typed, youknow, 20 timesorwhatever.
Itonlyappearedonce, anditwaitedformetostoptyping.
Sothat's, umthatissomethingthat I wantedtoteachyouguysisdebouncing.
Andit's veryimportantforthistutorial, especiallybecausewe'reupdating a database, um, throughtheuseoftheusertypingsothatcould, youknow, ifwehavehundredsandhundredsorthousandsandthousandsofusersandwe'reupdatingthedatabaseeverysingletime a usertypesofkey, that's gonnagetoutofhand.
Sowe'regonnause D bouncinginthistutorial.
Okay, sonowwhat I wanttodoisstartmakingthislook a littlebetter.
So I demonstrated.
Youknowwhatreactquilldoesandyouknow a littlebitaboutbouncing.
Sowhat I wanttodonowis I wanttostartfocusingongettingthesidebarcomponentsetup, andwealreadywentthroughgettingitemsfromthedatabaseon, youknow, assoonasweloadtheapp, wegetallofthenotesfromthedatabase.
Um, sonowthatwehavethesedestructioninsideofoursidebardotJsfile, I wanttogoaheadandremovehellofromthesidebar, and I wanttogiveour, umourparentsdidhear a classname, sogiveitclassnameandweusetheclassesobjectclasses, thatsidebarcontainer.
Allright, soinsideofhere, I wanttogoaheadandadd a buttonandit's gonnabe a buttonwith a Capital B, andthat's becauseitis a biguphere.
I canshowyou a, umitis a componentfromthematerialyou I corps, andwe'regoingtousethatbecauseit's goingtojustmakeitlook a littlebetterbydefault.
Wejustwantedtobetheoppositeandwealsowanttoresetthetitleandthereasonwhywewanttoresetthetitleisbecausewhenwe'readding a newnote, ifwestarttypingin a titleandthenwewanttostopadding a notewhenwegotoaddanothernote, wedon't wantthatprevioustitletostillbeintheinput.
Sowe'rejustgonnaresetthetitleandsave.
Let's seeifthatworksforus.
Okay, comeovertonewnote.
Andwhen I clickit, youcanseeNow I havethisinputhere, andwhen I starttotypeinsideofit, it's sayingitisactuallyloggingithere, asweexpected.
Andthenwhen I clicknewnote, itmakesitgoawaybecausewe'reflippingthatvariable.
When I clickitagain, youcanseeit's empty.
That's becausewe'reresettingthattitle.
That's exactlywhatwewantedtodo.
Buthere's theproblem.
When I clickNewNote, itstillsaysNewnote.
I wantedtosayCancel.
So I wantedtosay a newnoteherebecauseitmakessense.
I wanttoclickthat.
I wanttocreate a newnote, butnow I don't wantittosaynewknowanymore.