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 ServiceWorkerNotifications from './components/ServiceWorkerNotifications'
|
||||||
import AOS from './components/AOS'
|
import AOS from './components/AOS'
|
||||||
import Spinner from './components/Spinner'
|
import Spinner from './components/Spinner'
|
||||||
import { fetchContent } from './util/fetch-content'
|
|
||||||
import data from './data.json'
|
import data from './data.json'
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
|
@ -36,16 +35,17 @@ class App extends Component {
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
import('./util/fetch-content').then(({ fetchContent }) => {
|
||||||
this.setState({ loading: true })
|
this.setState({ loading: true })
|
||||||
fetchContent()
|
fetchContent()
|
||||||
.then(newData => {
|
.then(newData => {
|
||||||
this.setState(prevState => {
|
this.setState(prevState => {
|
||||||
const data = _merge(prevState.data, newData)
|
const data = _merge(prevState.data, newData)
|
||||||
return { data, loading: false }
|
return { data, loading: false }
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
.catch(() => this.setState({ loading: false }))
|
||||||
.catch(() => this.setState({ loading: false }))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocument = (collection, name) =>
|
getDocument = (collection, name) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue