From d45649adbd52956781cdf1c2d7c19554ef17e2c4 Mon Sep 17 00:00:00 2001 From: mottox2 Date: Tue, 5 Jun 2018 12:15:39 +0900 Subject: [PATCH 1/3] Update redux example for v2 --- examples/using-redux/gatsby-browser.js | 2 +- examples/using-redux/package.json | 6 +++-- .../index.js => components/layout.js} | 2 +- examples/using-redux/src/html.js | 25 ++++++++++--------- examples/using-redux/src/pages/a.js | 7 +++++- examples/using-redux/src/pages/b.js | 7 +++++- examples/using-redux/src/pages/c.js | 7 +++++- examples/using-redux/src/pages/index.js | 7 +++++- 8 files changed, 43 insertions(+), 20 deletions(-) rename examples/using-redux/src/{layouts/index.js => components/layout.js} (97%) diff --git a/examples/using-redux/gatsby-browser.js b/examples/using-redux/gatsby-browser.js index bb16b6799cf5f..da976f1f41470 100644 --- a/examples/using-redux/gatsby-browser.js +++ b/examples/using-redux/gatsby-browser.js @@ -4,7 +4,7 @@ import { Provider } from 'react-redux' import createStore from './src/state/createStore' -exports.replaceRouterComponent = ({ history }) => { +export const replaceRouterComponent = ({ history }) => { const store = createStore() const ConnectedRouterWrapper = ({ children }) => ( diff --git a/examples/using-redux/package.json b/examples/using-redux/package.json index e9fa9aa9007b6..e6a68f2dcaeed 100644 --- a/examples/using-redux/package.json +++ b/examples/using-redux/package.json @@ -5,7 +5,9 @@ "version": "1.0.0", "author": "Scotty Eckenthal ", "dependencies": { - "gatsby": "latest", + "gatsby": "next", + "react": "^16.4.0", + "react-dom": "^16.4.0", "react-redux": "5.0.5", "redux": "3.6.0" }, @@ -19,4 +21,4 @@ "build": "gatsby build", "serve": "gatsby serve" } -} \ No newline at end of file +} diff --git a/examples/using-redux/src/layouts/index.js b/examples/using-redux/src/components/layout.js similarity index 97% rename from examples/using-redux/src/layouts/index.js rename to examples/using-redux/src/components/layout.js index 4216a35cb7a73..6bc5a56c75a04 100644 --- a/examples/using-redux/src/layouts/index.js +++ b/examples/using-redux/src/components/layout.js @@ -44,7 +44,7 @@ class DefaultLayout extends React.Component { c - {this.props.children()} + {this.props.children} ) } diff --git a/examples/using-redux/src/html.js b/examples/using-redux/src/html.js index 4def894fa48c7..3c829e89f9cab 100644 --- a/examples/using-redux/src/html.js +++ b/examples/using-redux/src/html.js @@ -1,19 +1,11 @@ import React, { Component } from "react" import * as PropTypes from "prop-types" -const propTypes = { - headComponents: PropTypes.node.isRequired, - body: PropTypes.node.isRequired, - postBodyComponents: PropTypes.node.isRequired, -} - class Html extends Component { render() { return ( - + - {this.props.headComponents} - Gatsby - Redux + {this.props.headComponents} - + + {this.props.preBodyComponents}

A

+const A = () => ( + +

A

+
+) export default A diff --git a/examples/using-redux/src/pages/b.js b/examples/using-redux/src/pages/b.js index 6b15e3bd526e5..6d07016d0f645 100644 --- a/examples/using-redux/src/pages/b.js +++ b/examples/using-redux/src/pages/b.js @@ -1,5 +1,10 @@ import React from "react" +import Layout from "../components/layout" -const B = () =>

B

+const B = () => ( + +

B

+
+) export default B diff --git a/examples/using-redux/src/pages/c.js b/examples/using-redux/src/pages/c.js index 7e39f24fd0915..a54704ef0e9c6 100644 --- a/examples/using-redux/src/pages/c.js +++ b/examples/using-redux/src/pages/c.js @@ -1,5 +1,10 @@ import React from "react" +import Layout from "../components/layout" -const C = () =>

C

+const C = () => ( + +

C

+
+) export default C diff --git a/examples/using-redux/src/pages/index.js b/examples/using-redux/src/pages/index.js index 1a61860fb9334..560898bc64fbe 100644 --- a/examples/using-redux/src/pages/index.js +++ b/examples/using-redux/src/pages/index.js @@ -1,5 +1,10 @@ import React from "react" +import Layout from "../components/layout" -const Home = () =>

Home

+const Home = () => ( + +

Home

+
+) export default Home From c3a2f5087ed7bb0d4f6ea68ccfd08b948d25e979 Mon Sep 17 00:00:00 2001 From: mottox2 Date: Tue, 5 Jun 2018 20:09:06 +0900 Subject: [PATCH 2/3] Remove html.js --- examples/using-redux/src/html.js | 45 -------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 examples/using-redux/src/html.js diff --git a/examples/using-redux/src/html.js b/examples/using-redux/src/html.js deleted file mode 100644 index 3c829e89f9cab..0000000000000 --- a/examples/using-redux/src/html.js +++ /dev/null @@ -1,45 +0,0 @@ -import React, { Component } from "react" -import * as PropTypes from "prop-types" - -class Html extends Component { - render() { - return ( - - - - - - - - Gatsby - Redux - {this.props.headComponents} - - - {this.props.preBodyComponents} -
- {this.props.postBodyComponents} - - - ) - } -} - -Html.propTypes = { - htmlAttributes: PropTypes.object, - headComponents: PropTypes.array, - bodyAttributes: PropTypes.object, - preBodyComponents: PropTypes.array, - body: PropTypes.string, - postBodyComponents: PropTypes.array, -} - -export default Html From 53ab99ce42a91c8b26782dd6bebfbed823a4b44f Mon Sep 17 00:00:00 2001 From: mottox2 Date: Tue, 5 Jun 2018 22:54:16 +0900 Subject: [PATCH 3/3] Use ES6 export --- examples/using-redux/gatsby-ssr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/using-redux/gatsby-ssr.js b/examples/using-redux/gatsby-ssr.js index 7241238698300..5d615775ab0fe 100644 --- a/examples/using-redux/gatsby-ssr.js +++ b/examples/using-redux/gatsby-ssr.js @@ -4,8 +4,7 @@ import { renderToString } from 'react-dom/server' import createStore from './src/state/createStore' -exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { - +export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { const store = createStore() const ConnectedBody = () => (