React JS Yazalım 1
Parent componentini Child1 ve Child2 componenti ile güncelleyelim. Reactda state güncelleme işlemi yapacağız. Parent componentim name ve password alanlarımdan oluşuyor. Name inputum child1 componentimde. Password inputum ise child2 componentimde. Yavru komponentlerimin state tutmadan direk ata komponentimi güncellemelerini istiyorum bunun içinde iki tane yöntem ile yapabilirim 1. yöntem parent komponentimde child komponentimi çağırırken props olarak parent komponentimin methodunu child komponentime göndermem. 2. yöntem ise üst scope da method tanımlayıp bunu child komponentimde ulaşmak. import React , { Component } from " react " ; class Child1 extends Component { render () { this . state = { name : "" } return ( < div > < label > Name: </ label > < br /> < input type = " text " placeholder = " Name " onChange = { e => this . prop...
Yorumlar
Yorum Gönder