0% found this document useful (0 votes)
87 views25 pages

FSD-II Notes

react notes

Uploaded by

Yash Kadam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
87 views25 pages

FSD-II Notes

react notes

Uploaded by

Yash Kadam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 25
that is React Js 7 tee rary ‘or ui Idi ng eusa 7 7 ay aaa OM Ronents fe 7 ; £CE component ct Ere —. end library | which is responsible "on} i 77 layer sf the application ie Tt wey initialy developed & Maintained by facebook K Llhyy We use React Js 7 D-1t is used 40 develop the UI thot: improve * the peed 2). If uses yirbugl bom (po umepk Object Model) which improves the performance “ot ihe Opp The 4S virtual pom - which im proves the performance of the app. | >. The JS virtual pom is faster than the ‘ _regulay Dom - econ _u: Reacl Is on the client | & server side language. : | 4). Tt use. om pon nts % dato patterns thot Limprove_tead ability 2 mainlain Laeger op i ). Reack wil) handle efficiently updah ng & { rendering of the component i 2 Xx React Js features ~ Dd, Tsx- ).T5, fonds for JovoScript § Hr W.Tt Is To aScript nynkan extension. : un). This Syntax iS praceed inte 1s_calle 7 4 ; : React framework @ scanned with OKEN Scannerthe Ese. is I oplimize U2 _updates by creating a ligt! _——tweight_cepy identify changes selectively ae SS = pdating only seleve clive Parl, roinimizin: a performance jerhend enhancing the us - 0 Besct je 1c ail aba! components a perience - 1) React TS oppi? ic made up of enullip components § each Cam ponent ha: logis and contra! DReoct IS uses ISK Files which make the = “This cempanents can be revsable whic} Oppl® simpie 2 the code wells understand| helps you tn maintain code i henciseriing on Wide know that the React 15 is a component = Jayer Srole project hosed approach which makes the cole reusabi os _you cf. ———2One_way data binding . React Is_ig d@aigned in guch a ©): Performance = that follows wnidirectional data flow D-T) Jo ‘known as tp be great performance ES The benefit of unidirectional data flow Its features rmokes it much better than ol - is_gives yay betier performance th" appl”. frameworks: The teagon behind this thot ie mite The doko flow i nether clirech managed yDom, E then it ea, ditions) feature . It is “The poe i =platforrs § pragrammin = be the components are supposed ty be APL which deals with fTmi, xmU, xiir mt, routable the dota will b them canna W). The bom exists entirely (in a ‘memoy be chong - luc fe this when we reate q component wwe did_not write directly js nom.” 8: Virtual Dom = 2.1) igo tepresentolion of the engine! _b eos : 2 Ei )."Foay to lear ae Ip works like © late binding _ whe: Creating dynamic meb appl? became casie “ang modification happenin the le component = Hn) Performa, hancement = React 75. impr, nj: The entire O01 is terender in presentotion 2 new bom. performance rhual bom : cress _platferm § proqe @ scanned with OKEN ScannerTo clot meyer = nem atest API which deals ith bi xm and xHTML, mes! of the develeper fac reate_project folder - a om s_deyelaped which slaw down th 3 reate-react-app pyajest_ nay performance hut Reacl Js salve this prob npm install create- react-opp = hy virtual | ages r. i ae teate-teact-opp project na demo. project : project (open with cede) Difference bet” npm_and_npx + Traditionally 35 fra kk haye_an issue ip = : deali| ith SEQ. Mony web developers have np: ppm ffer problems in other longquages with seo Reocl Js overcemy this problem deyelopes D np» reate -react- apy D npm instol| create nevigated _variou: rch engi ____praject_nam. reoct opp ~ “create —rench= app Benefit of having ts library = project_name =) 5 The Js library ids more flexi develspers they oni 2. npe is the npm. 3. npm is the ned package runner package manager * Disadvantages = ). The high pace of a development 2. 1o _npx without inst. 9. npm ingialling libraries ips eape Anion eohone 3 diling any’ pockag dependencies using mene get project npr “Isx igo howiew 7-1 Reael Js us sx. 1¥s syntax extension thot allow HTML. with- 5 _onix fogedhe % About React sx Te_sinp this approach has its benefits D-sx is the xm | rm based syntax hut seme members of the development Lension = mrmunity consider Ts a3 _o harriey spe! O-I's o way te write 15 code using _ _ for pew deve oper: Le waplexity in th. xm) Home eaving cu Tsk isa integral part of hew every @ scanned with OKEN Scannercleveloper writes components export default searchbox = 278% elements to represent. custo: ce = cornpanents + So it is alan called user defing Comment = -erepone nts Monwally se tf yon Create Componen? nay Code on + s oput you “can moke use of such com: CEMpOReNts te prapshron erbiere y)_ather campenents by usin: elemen ‘omponenta = Components ore putin ave oder 7 - All_elements mous be closed Component in Peact serve _as independent f = Elements tha hove child node muy Feusoble Code black fox_u1_elemnent jee Nosed. . They represent diff parts of web peg = Atti butes that Strings oust he rain hotn tructune § hehaviour - quote: around therm Ther re th reusable code blocks contoinira] 2 = Ist ust he eturned in lower ca: logics § UT elements elements. mpenent promoke: efficiency g Scalabiiity web development in allowing developers fo # Some reser words — rapa § customize aethey needed class closstame fi him! for __React_companent = dik = onClicte 1 React component are the building black oF cz Bate ermine ack appl? saa qubmnil -_onSubmit Reusable code block canfaining logic _hlorks | “2 pr elements. A Ul is broken down inte ~#_ Syntay of custom / user- defined _componente= Iple individual pieces called ponents ip aes aneea RESTS You_con ark on component independently 3 a then merge them oll ints”-c “parent compen=at const € Geach Tere , SetSearch Term I= 3_then “App usestote (Ds r —— ponent heve +we type function compon- _teburn § ent aml class component q diy_id= "search-box" best suited need fo int companent i the components cleesnt t @ scanned with OKEN Scannera Eunchen components fee oa ee - a Simple _cemponents —fogeth, Patent cempoy + React props - props stands for properhies they are read a 2). Clazs_component ‘enly_" component ° re_Complex” than FuncHen compen. Tt is_on bjec! Which store the value oF - it Otbibute oF tag” and were imilgr to the value It _teyuire you t= extend from read of attrinste of tog ond pork tegether similar be e omponent “ond freate render funchon the html attribute : Tk pelurn reach clemen’ pisps_ore_immuteble 5: con nat a Yeu_can pass date from classy _ather class modify! thie 1S from Inside the component ompanent import React from “react function component = port const Demo = ( props) = ate irnport React from“ react" i z return function Greet bY Hello. f props name} Hello, Good PMorning Sth"? d @ scanned with OKEN Scanneri age jo [mPstt_Peact._{ Component } from "reads _ ae lass Messag, tends Component compenent © - ae instructor ¢) constructor (> i me sper perc ee ae thi tate = 7 ne ssage : | elcome: visitars? ——______t = i chonge Message © — £ this. seiStale ({ i Shis. seistate (f thie. Stale number 1 message *' thant you fer qubanitin a » _ 4 Ee render Of this. setStoted return ( humber = this state. number -!
» - port _clefaut Message _ Hello, my nome is {namey and i worleing in work F. 5 export _defaull Greet f @ scanned with OKEN Scannerncliens that are pari of react which give you access dy fealine f were Hire include state £ life cyde _§ _catchin: f Function results Hooks ' hook inte’ Réack from functon Rules V). Heeks can _only_be used in function component : t 2). Hooks mus} be called at the top level of your function. “Component - meaning inside the function but net inside of statement or inner funchen. Becouse heeks need frem te run just one every time . Your function components runs: they’ can! be called rem inside of ‘condiHonal stete loops or nested funchon. Buili-in “Hooks = ). usestete aj. use Effect 3. useContert W). useReducer © 5). uge Callback . 6). useMemo 2. ugetrnperotiveHandle s). _useRef 5). uselayoutt ffect to). ise DebugNalue & @ scanned with OKEN Scanneruses estates from TE_gaur Component cn fcount} = ¢} bution’ as export defaull Counter, 3. Grtpata js = import React, % yecsiabe 3 From _* reach” ~~ im port _{ Bullen} from ““react- beetstrap” function Gelbata © “Welcome "DF oe 2 = i geiDppertext {> Conver! > pork defeult GelDala 9 usestobe 3 From * reach uijon J from * react- Bootstrap’ singe p2__TS0Ft. Shringlfy Cfultiame. ent + fuurtome 1) }

1a __Shew. Get Array FeO function fusName length (Updating ae s a mponent life cycle has tree main pl = * yolue =f name} D- Mounting phase — legate £22) getname CO} In_when component is created e-texget ted_in Coppje) into the pom > ao = The updating phase accu when a com Inmnount phase — —_usetffect Hook - : React useef such_as__fechiny _ These hooks “june is also a way of using dependeny array @ scanned with OKEN Scannerwhich we con u funchena) Setting up a _subseriplion_o» 2b (3 used fe mimic tne af tos based _carnpanent Syntow ae mport React . f usestote use€Flect from ‘reach a function, Demet) yD) eae Callbade function? Contain_the code te, hes the use _effeck digger Dependency: oe IL 1 an optional pore, suse! when the given _trample - UseFfectHoole js ~ component such Inport f_usestate , use Effect function use ffect Hook Of const [counts sehGeun: suseltfed (CO rf console tog C0" Only: stake contro!_the ix_used_fe hondle a side ofica aa import { useSinie ,_usccfect} fram “react function _use EffectHook 0 } Casuat, setcounter] > uaesianteh? const C msg, setmeg] = useStote(“Hel!0') usebFfed (0 = - ‘i — ee JetTime Out C0) => ie a ae! can Pas. C Good Morning") 5 _ dependensy js_change mounted — soStete Co) @ scanned with OKEN Scanner—— te = tesponge-json © then (json ~ console Jog Cjson)) JL. Lressurcetype)) Seitems e fetch (' hHpe: I! joonplacenalder - hy picede con $ {_resaurcely pe “then (rss pons =} tespenae:jgon 0) YT radu ch list mport React. { Soe peoesceeo aaa const [dota , setdata] = useStete (C2) __ [7 prods reluen ( _ Pests set Resource Ty pe “users ‘J%2 Users 4, tet oir) = 10,12, 447 ae a let area = Clo,ia, 31g ~ console leg Carel == ara) is required % —fensole.leg CoriginalArray)+ nsele log C copiedAray )> @ scanned with OKEN ScannerUsePel Hook + EDOM cituclune manipulation UsePet hook ae = UseRef_is_a_renct_haok thal lets Aeterence 6 volue thats __tendering isdonet ie — usRe[ Cimbal value) 3 Exomple | ees = ——imperi React, f yackel} fem “yeas o-———__-firnetion_tayCemponent © Se zt Tons! _inihalret useReF(O)s cons) inihislPef = ysorel (mui ____ Text Reader js fusePef} from -react Text Reader 0 ong! _fealYiew 2 usePet Co), iperYal textiew current focus 0) —textView current slyle_harhgraundte Initial value at The value you pant te ref object "current properly” do be“ inikially . + can be value of a ‘any dype z de useRef T_tetums on object a single property. port defaul} TextReder current C properby) Tnifiauy i+ set to the joHal value you Red fs color change hove passed, if you passed the reference obj. to_reack as o reference ottribute to JSx node —reoct oil! set its current property. crenge Take_a textbox os user in pub a color name background celer_shovid be changed using the ugereF §_usestate. @ scanned with OKEN Scannerouter —__——~ eee ae een Simiby te Link but provides omipenent within your oj —_———sitributes hen the link ig ocHve ee redone eee — iene Example —Yarloie com penenr ins reoch appt alloys aie aS ranging the browser ul and teep the ae —.—it—=™ sync aja ith the a Se cee eee fois Feoluve of the react router impart —toleleomefrem__{-corapanentel (fel a import {@rowserRouter a3 Router. Route, Link , Poutes} Ee 3. Decorative routes [cas yet router dem" 5 2 navigation function App 0) 2): Trngrrove typescript support Browaer Poulter - the __iheod : —eoute_poth = */ Hello” Component? aerrs + "Tileleome"¥ Component =Funchon seer const para = use feroms 0 onsh f. = pore i return ( ‘ =

This ig all about ser informahon “Ip Tempony'> Compony Contact) Pontark Js {yank E 5 : i export _defoult User Apo path=" Contoct” Component T Contacts} ¢? @ scanned with OKEN Scanner 1 | ener | witch Cachon. type) + - a — #| Hements ! hinaplen alae Ease case Buy Coke: — as z 7 return 4 1 Adion + a ae ieee : o ——The only way your application con with the . neoftakes ' slate. nodfcakea -1 | Inlernal store. - Cay. some information from your appl” te operatis SSS VR. Gave @ scanned with OKEN Scanner“at en default return St Lcenst Bug ca This ports Create _one_sto ate chon § reducer 109 ore for the entice asp” fo state Ho getsiared ocress to state to be updobed: Sirst redue action Gispatch (action) for any ape)” = ake a To register i fener Hrrough Subscribe listener) funchon. nat _redue = require (\redux:) function consl_crentestore. reborn 5 if a tL 2: Reducer ous i Th sperify L- “fe action” send ( agimmente qo erample Jelog_ Cupdale 3 const ini pate Cb teh C bugeakeo) To fe ee clon ae redux = require (0 calzec) sedus cy ciealeStare 4 > Bay Cake" pesOR ES BEM 0. PRS eels 8 O'S props. 3 ———~-__numof takes :10 _ = cose guy Cake‘ relurn P Spend operolas. stote, — “recs the copy oF SrTay om f stot etait Ez imofCakes ! slate. numafCakes -1 ; ent ioialsiote =F aa. ee ee ee ee ——fonst_reducer = (stote = jnitialStale, acon) =~} clefault | return state, 2. Create cokes folder ¢ Steps - By L_ Create redux folder in sxe/cemponen! folder. a atm cakes folder create Hwee 15 file My - E D:_Cokenction j = 4 1). Cake Reducer. ~ ww). Cakelyeee js = “tons! store = crealeslore (reducer) 4. In redux feller create sicrejs congale.lag (" Initio! stare yalve”, slere getsjateo) S- In componen} feldey CakeContoine: js lore. subscribe (0 => f congolelog (“Updated siare stole” ‘slore. gelatatau) 3 2 D oe __ store dispalch (buytate 0); pei -_store. dligpalch ChuuCoke 1): fore-dispateh (buyCoke (3); UT part for coke appl”. G In Appjs impot Provide. from peactredus —__and_stere import store fem ca __store In_App.ja_provider_companent sarap all —compenents § ‘slote_paas in Prayide _23_on_prop Oa Be he @ scanned with OKEN ScannerSe function hontiesubmit cacleis preventnefault C) > Authentication and authorization : [ment _enauring thet user hove secure ccs ‘They_ore fundamental oapecta of ch _devsias of verifying the Identity of o user “aypically_ th Hole such a5 user “E_con be Include addifional factor feet apsu 1 -foctor_authenticotion biometrics cons fe lestog (“You clicked gubmit")i That is Authorizahion method Snce authenticated determine what action and Ke. ~ =] Tyesourcea a user i allowed fo thin the Da return HH) Jex ot cade “= appl” ; Kata fj broees 2 Fiero uthorization invalyes defining “ond «enforcing jeslona ond previledges based on the wer idenbity 9) | and role ‘ = 4 i [Hypes. of Authorization » 3 T ie i 1 Cenfralized Authorization planagem ent 4 7 | Streamlining the Implementation of Bele Bosed A ntrel Across the Appl” ole: Authentication ort React, { usestate} from ut react i function _Loginfage ©) - L : : consi ( isloggedin _schis lagged{n] = usestate Cn fundion Authveer 0 a | ——— aan ee a @ scanned with OKEN Scannerf return { ‘a u io} Tat i {f lia. isloggedrn 2 |

Welcome user islogged in Legin [~ _ I button | 3 |——— { ishdmin ? penis @ scanned with OKEN Scanner

You might also like