File tree Expand file tree Collapse file tree 3 files changed +18
-24
lines changed Expand file tree Collapse file tree 3 files changed +18
-24
lines changed Original file line number Diff line number Diff line change @@ -9,22 +9,28 @@ import get from 'lodash/get'
9
9
import { deslugify } from '../lib/helpers'
10
10
11
11
class Section extends Component {
12
- lastSectionId = null
13
-
14
- componentWillReceiveProps ( props ) {
15
- if ( ! props . section ) {
12
+ viewedSection = id => {
13
+ if ( ! id ) {
16
14
return
17
15
}
18
16
19
- const sectionChanged = props . section . id !== this . lastSectionId
17
+ setTimeout ( ( ) => {
18
+ this . props . viewedSection ( {
19
+ variables : { id }
20
+ } )
21
+ } , 2000 )
22
+ }
23
+
24
+ componentDidMount ( ) {
25
+ this . viewedSection ( get ( this , 'props.section.id' ) )
26
+ }
27
+
28
+ componentDidUpdate ( prevProps ) {
29
+ const { id } = this . props . section
30
+ const sectionChanged = get ( prevProps , 'section.id' ) !== id
20
31
21
32
if ( sectionChanged ) {
22
- setTimeout ( ( ) => {
23
- props . viewedSection ( {
24
- variables : { id : props . section . id }
25
- } )
26
- } , 2000 )
27
- this . lastSectionId = props . section . id
33
+ this . viewedSection ( id )
28
34
}
29
35
}
30
36
Original file line number Diff line number Diff line change @@ -2,25 +2,16 @@ import React from 'react'
2
2
import ReactDOM from 'react-dom'
3
3
import { ApolloProvider } from 'react-apollo'
4
4
import { BrowserRouter } from 'react-router-dom'
5
- import { MuiThemeProvider , createMuiTheme } from 'material-ui/styles'
6
5
7
6
import './index.css'
8
7
import registerServiceWorker from './registerServiceWorker'
9
8
import App from './components/App'
10
9
import { apollo } from './lib/apollo'
11
10
12
- const GRAPHQL_PINK = '#e10098'
13
-
14
- const theme = createMuiTheme ( {
15
- palette : { primary : { main : GRAPHQL_PINK } }
16
- } )
17
-
18
11
ReactDOM . render (
19
12
< BrowserRouter >
20
13
< ApolloProvider client = { apollo } >
21
- < MuiThemeProvider theme = { theme } >
22
- < App />
23
- </ MuiThemeProvider >
14
+ < App />
24
15
</ ApolloProvider >
25
16
</ BrowserRouter > ,
26
17
document . getElementById ( 'root' )
Original file line number Diff line number Diff line change @@ -10,9 +10,6 @@ export const USER_QUERY = gql`
10
10
email
11
11
photo
12
12
hasPurchased
13
- favoriteReviews {
14
- id
15
- }
16
13
}
17
14
}
18
15
`
You can’t perform that action at this time.
0 commit comments