-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialState.js
More file actions
44 lines (33 loc) · 920 Bytes
/
InitialState.js
File metadata and controls
44 lines (33 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Establecer estado inicial
// Un componente React puede acceder a información dinámica de dos maneras: propsy state.
// A diferencia props, unos de los componentes statees no pasaron desde el exterior
// Para hacer que un componente tenga state, dele al componente una statepropiedad
class Example extends React.Component {
constructor(props) {
super(props);
this.state = { mood: 'decent' };
}
render() {
return <div></div>;
}
}
<Example />
// Este objeto representa el "estado" inicial de cualquier instancia de componente
// Example
import React from 'react';
import ReactDOM from 'react-dom';
class App extends React.Component {
// constructor method begins here:
constructor(props) {
super(props);
this.state = { title: 'Best App' }
}
render() {
return (
<h1>
Wow this entire app is just an h1.
</h1>
);
}
}
<App />