React JS. esas meqamlar

props ve state haqqinda

props bir componentden digerine data dashimaq uchun istifade olunur.

state ise bir basha componente aid olan bir ozellikdir. state deyishdiyi zaman componentin render funksiyasi ishe dushur ve sehife yeniden generasiya olunur.

bele bir veziyyet dushunek ki, Parent componentden child component e bir data gonderirik. bu data parentin statein de saxlanib. 

<Child someData = {this.state.someData}> </Child>

bu child component bu data ile her hansisa html generasiya eleyir. daha sonra parent componentin state datasi deyishir. burda bele bir hal yaranir ki, child a gonderilen data bir basha parent in datasindan asilidir. parentin datasi deyishdiyine gore child in da datasi deyishir ve yeniden render funksiyasi ishe dushur.


method istifadesi

addToCart = (product) => {
   alert(product.productName + " added to cart!");
}

<Button
    onClick={() => this.addToCart(product)}
    color="success">
    <span style={{ fontWeight: "bold" }} >+</span>
</Button>

react da esas meselelerden biri de methodlarin componentlerde istifade olunmasidi. bunun uchun birinci component hemin method a bind olunmalidir. daha sonra ishletmek mumkundur. 3 yol movcuddur

1. constructor vasitesile
2. methodu cagrildigi vaxt bind elemek
3. ve ya methodu arrow shekilde yaradib ele arrow sheklinde de istifade etmek. (yuxardaki numune)


route ve react strap taglarinin qarishmamasi uchun hell yolu (navbar)

https://github.com/reactstrap/reactstrap/issues/1285#issuecomment-446592497

to be continued ..

Comments

Popular posts from this blog

Validation for AZ phone numbers with RegEx in Java

Java necə işləyir, kod nədir ?

@Transactional annotation haqqinda. Cascade istifade olunmasi