Dynamically import preview-mode script
This commit is contained in:
parent
5f5fdd5d2e
commit
4b5aac0edd
1 changed files with 10 additions and 10 deletions
20
src/App.js
20
src/App.js
|
|
@ -15,7 +15,6 @@ import GithubCorner from './components/GithubCorner'
|
|||
import ServiceWorkerNotifications from './components/ServiceWorkerNotifications'
|
||||
import AOS from './components/AOS'
|
||||
import Spinner from './components/Spinner'
|
||||
import { fetchContent } from './util/fetch-content'
|
||||
import data from './data.json'
|
||||
|
||||
class App extends Component {
|
||||
|
|
@ -36,16 +35,17 @@ class App extends Component {
|
|||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
this.setState({ loading: true })
|
||||
fetchContent()
|
||||
.then(newData => {
|
||||
this.setState(prevState => {
|
||||
const data = _merge(prevState.data, newData)
|
||||
return { data, loading: false }
|
||||
import('./util/fetch-content').then(({ fetchContent }) => {
|
||||
this.setState({ loading: true })
|
||||
fetchContent()
|
||||
.then(newData => {
|
||||
this.setState(prevState => {
|
||||
const data = _merge(prevState.data, newData)
|
||||
return { data, loading: false }
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => this.setState({ loading: false }))
|
||||
.catch(() => this.setState({ loading: false }))
|
||||
})
|
||||
}
|
||||
|
||||
getDocument = (collection, name) =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue