-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_app.tsx
40 lines (35 loc) · 987 Bytes
/
_app.tsx
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
import NextApp from 'next/app'
import React from 'react'
import { Provider } from 'react-redux'
import { SWRConfig } from 'swr'
import fetch from 'unfetch'
import store from '../utils/store'
interface Props {
Component: any,
router: any,
ctx: any
}
class App extends NextApp {
render() {
const { Component, pageProps } = this.props
const header = <h2>Header</h2>
const footer = <h2>Footer</h2>
const backUrl = process.env.back_url
const swrConfig = {
refreshInterval: 3000,
fetcher: (service: string) => fetch(`https://${backUrl}/${service}`).then(res => res.json())
}
return (
<SWRConfig
value={swrConfig}
>
<Provider store={store}>
{header}
<Component {...pageProps} />
{footer}
</Provider>
</SWRConfig>
)
}
}
export default App