-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
37 lines (35 loc) · 892 Bytes
/
App.js
File metadata and controls
37 lines (35 loc) · 892 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
import React, { Component } from 'react'
import logo from './logo.svg'
import './App.css'
class App extends Component {
state = {
a: 331,
mockData: []
}
show = async () => {
// await alert(123)
}
componentDidMount () {
fetch('/task-list')
.then(res => res.json())
.then(mockData => this.setState(Object.assign({}, this.state, { mockData })))
}
render () {
this.show()
return (
<div className='App'>
<div className='App-header'>
<img src={logo} className='App-logo' alt='logo' />
<h2>Welcome to React {this.state.a}</h2>
</div>
<p className='App-intro'>
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<p>
mockData: {JSON.stringify(this.state.mockData)} (from: mock/TaskList)
</p>
</div>
)
}
}
export default App