Skip to content

Commit f441b51

Browse files
committed
Check if section prop is defined
1 parent 3ec38da commit f441b51

File tree

6 files changed

+5
-135
lines changed

6 files changed

+5
-135
lines changed

src/components/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import TableOfContents from './TableOfContents'
88
import Section from './Section'
99
import CurrentUser from './CurrentUser'
1010
import Profile from './Profile'
11-
import Reviews from './Reviews'
1211

1312
const Book = ({ user }) => (
1413
<div>

src/components/Section.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class Section extends Component {
2222
}
2323

2424
componentDidMount() {
25-
this.viewedSection(get(this, 'props.section.id'))
25+
if (this.props.section) {
26+
this.viewedSection(this.props.section.id)
27+
}
2628
}
2729

2830
componentDidUpdate(prevProps) {

src/index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,16 @@ import React from 'react'
22
import ReactDOM from 'react-dom'
33
import { ApolloProvider } from 'react-apollo'
44
import { BrowserRouter } from 'react-router-dom'
5-
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles'
65

76
import './index.css'
87
import registerServiceWorker from './registerServiceWorker'
98
import App from './components/App'
109
import { apollo } from './lib/apollo'
1110

12-
const GRAPHQL_PINK = '#e10098'
13-
14-
const theme = createMuiTheme({
15-
palette: { primary: { main: GRAPHQL_PINK } }
16-
})
17-
1811
ReactDOM.render(
1912
<BrowserRouter>
2013
<ApolloProvider client={apollo}>
21-
<MuiThemeProvider theme={theme}>
22-
<App />
23-
</MuiThemeProvider>
14+
<App />
2415
</ApolloProvider>
2516
</BrowserRouter>,
2617
document.getElementById('root')

src/lib/apollo.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { getMainDefinition } from 'apollo-utilities'
77
import { setContext } from 'apollo-link-context'
88
import { getAuthToken } from 'auth0-helpers'
99

10-
import { errorLink } from './errorLink'
11-
1210
const httpLink = createHttpLink({
1311
uri: 'https://api.graphql.guide/graphql'
1412
})
@@ -39,7 +37,7 @@ const wsLink = new WebSocketLink({
3937
}
4038
})
4139

42-
const networkLink = split(
40+
const link = split(
4341
({ query }) => {
4442
const { kind, operation } = getMainDefinition(query)
4543
return kind === 'OperationDefinition' && operation === 'subscription'
@@ -48,8 +46,6 @@ const networkLink = split(
4846
authedHttpLink
4947
)
5048

51-
const link = errorLink.concat(networkLink)
52-
5349
const cache = new InMemoryCache()
5450

5551
export const apollo = new ApolloClient({ link, cache })

src/lib/withAuth.js

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/lib/withUser.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export const USER_QUERY = gql`
1010
email
1111
photo
1212
hasPurchased
13-
favoriteReviews {
14-
id
15-
}
1613
}
1714
}
1815
`

0 commit comments

Comments
 (0)