Funções
Objetos
class Animal {
}
constructor(nome){
}
this.nome = nome;
const meuAnimal = new Animal("rex");
console.log(meuAnimal.nome);
// "Não Faca Isso"
class Animal {
}
constructor(nome){
}
this.nome = nome;
const meuAnimal = new Animal("Rex");
getNome(){
}
return this.nome;
setNome(novoNome){
}
this.nome = novoNome;
console.log(meuAnimal.getNome());
// "Rex"
meuAnimal.setNome("Fofucho")
console.log(meuAnimal.getNome());
// "Fofucho"
class Cachorro {
constructor(nome){
}
}
extends Animal
super(nome);
falar() {
console.log("Au Au")
}
rolar() {
console.log("*rolando*")
}
const meuCachorro = new Cachorro("Rex");
console.log(meuCachorro.getNome());
// "Rex"
meuCachorro.falar();
// "Au Au"
class Gato {
constructor(nome, raca){
}
}
extends Animal
super(nome);
falar() {
console.log("Miau")
}
const meuGato = new Gato("Mingau", "Siames");
console.log(meuGato.getRaca());
// "Siames"
meuGato.falar();
// "Miau"
this.raca = raca;
getRaca() {
return this.raca
}
filho
filhos
<div>
<HeaderComponent />
<NavBar />
<FooterComponent />
</div>
<div>
<NavIcon />
<NavIcon />
<NavIcon />
<NavIcon />
</div>
App {
HeaderComponent
NavBar {
NavIcon
NavIcon
NavIcon
}
FooterComponent
}
render(){
return(
<div>
<NavIcon nome="Google" link="www.google.com"/>
<NavIcon nome="Face" link="www.fb.com"/>
</div>
);
}
class NavIcon extends Component {
render(){
}
}
return(
<div>
<a href={this.props.link}>{this.props.name}</a>
</div>
);
this.props = {
name: "Google",
link: "www.google.com"
}
this.props = {
name: "Face",
link: "www.facebook.com"
}
class NavIcon extends Component {
render(){
return(
<div>
<a href={this.props.link}>{this.props.name}</a>
</div>
);
}
}
const navIcon = (props) => {
}
return(
<div>
<a href={props.link}>{props.name}</a>
</div>
);
class MeuComponente extends Component {
}
state = {
}
meuCampo: 'umValor',
outroCampo: 'outroValor',
this.setState(
);
{
meuCampo: 'umValorDiferente'
}
console.log(this.state.outroCampo);
Updating
UnMounting
Mounting
getDefaultProps
getInitialState
componentWillMount
render
componentDidMount
getDefaultProps
getInitialState
componentWillMount
render
shouldComponentUpdate
componentWillUpdate
render
componentDidUpdate
shouldComponentUpdate
componentWillUpdate
render
componentWillUnmount