Skip to content

Commit aac97e8

Browse files
committed
fix [object Object] 2
1 parent 783d60f commit aac97e8

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

gatsby-browser.js

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
1+
// import React from 'react'
2+
// import {Provider} from 'react-redux'
3+
// import createStore from './src/createStore'
4+
//
5+
// const store = createStore()
6+
//
7+
// exports.wrapRootComponent = function wrapRootComponent({Root}) {
8+
// return function wrapRootComponentComponent(props) {
9+
// return (
10+
// <Provider store={store}>
11+
// <Root />
12+
// </Provider>
13+
// )
14+
// }
15+
// }
16+
//
17+
//
18+
//
19+
//
20+
//
21+
//
22+
//
23+
//
24+
125
import React from 'react'
2-
import {Provider} from 'react-redux'
26+
import { BrowserRouter as Router } from 'react-router-dom'
27+
import { Provider } from 'react-redux'
28+
329
import createStore from './src/createStore'
430

5-
const store = createStore()
31+
exports.replaceRouterComponent = ({ history }) => {
32+
const store = createStore()
33+
34+
const ConnectedRouterWrapper = ({ children }) => (
35+
<Provider store={store}>
36+
<Router history={history}>{children}</Router>
37+
</Provider>
38+
)
639

7-
exports.wrapRootComponent = function wrapRootComponent({Root}) {
8-
return function wrapRootComponentComponent(props) {
9-
return (
10-
<Provider store={store}>
11-
<Root />
12-
</Provider>
13-
)
14-
}
40+
return ConnectedRouterWrapper
1541
}

gatsby-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ exports.modifyWebpackConfig = function modifyWebpackConfig({config, stage}) {
8484
atob: function atob(str) {
8585
return new Buffer(str, 'base64').toString('binary');
8686
},
87+
location: {
88+
pathname: ''
89+
}
8790
}
8891
})
8992
}

gatsby-ssr.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react'
22
import { Provider } from 'react-redux'
3+
import { renderToString } from "react-dom/server"
4+
35

46
import createStore from './src/createStore'
57

@@ -12,5 +14,5 @@ exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
1214
{bodyComponent}
1315
</Provider>
1416
)
15-
replaceBodyHTMLString(<ConnectedBody/>)
17+
replaceBodyHTMLString(renderToString(<ConnectedBody/>))
1618
}

src/templates/Tutorials.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Tutorials extends React.Component<Props, null> {
101101
nextChapter={nextChapter}
102102
n={n + 1}
103103
showBonus={showBonus}
104-
path={location.pathname}
104+
path={this.props.location.pathname}
105105
/>}
106106
</div>
107107
</div>

0 commit comments

Comments
 (0)