Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby-plugin-offline doesn't work with Redux #7053

Closed
kaumac opened this issue Aug 6, 2018 · 1 comment · Fixed by #7355
Closed

Gatsby-plugin-offline doesn't work with Redux #7053

kaumac opened this issue Aug 6, 2018 · 1 comment · Fixed by #7355
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@kaumac
Copy link
Contributor

kaumac commented Aug 6, 2018

Description

Whenever I add Redux to Gatsby, gatsby-plugin-offline stops working. The service worker is registered, but the offline functionality doesn't work

Steps to reproduce

  1. Create a new project from https://github.com/gatsbyjs/gatsby/tree/master/examples/using-redux/
  2. Add gatsby-plugin-offline
  3. Deploy and test offline

This setup is deployed here if you want to try:
https://staging.maze.design/
(You can see the issue with SW on the console)

Expected result

The site should continue to function while offline

Actual result

The site doesn't work offline

Environment

System:
    OS: macOS High Sierra 10.13.5
    CPU: x64 Intel(R) Core(TM) i7-3635QM CPU @ 2.40GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.7.0 - ~/.nvm/versions/node/v10.7.0/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.1.0 - ~/.nvm/versions/node/v10.7.0/bin/npm
  Browsers:
    Chrome: 67.0.3396.99
    Firefox: 61.0
    Safari: 11.1.1
  npmPackages:
    gatsby: 2.0.0-beta.69 => 2.0.0-beta.69
    gatsby-plugin-offline: 2.0.0-beta.6 => 2.0.0-beta.6

File contents (if changed)

gatsby-config.js: ```module.exports = {
siteMetadata: {
title: "Gatsby Redux",
},
// In your gatsby-config.js
plugins: ["gatsby-plugin-offline"],
};

`package.json`: ```{
  "name": "gatsby-example-redux",
  "private": true,
  "description": "Gatsby example site that shows use of redux.",
  "version": "1.0.0",
  "author": "Scotty Eckenthal <scott.eckenthal@gmail.com>",
  "engines": {
    "node": "10.7.0",
    "yarn": "1.7.0"
  },
  "dependencies": {
    "gatsby": "2.0.0-beta.69",
    "gatsby-plugin-offline": "2.0.0-beta.6",
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "react-redux": "5.0.5",
    "redux": "3.6.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "develop": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "heroku-prebuild": "rm -rf .cache && rm -rf public",
    "heroku-postbuild": "gatsby build"
  }
}

gatsby-node.js: N/A
gatsby-browser.js: ```import React from 'react'
import { Router } from 'react-router-dom'
import { Provider } from 'react-redux'

import createStore from './src/state/createStore'

const store = createStore()

export const replaceRouterComponent = ({ history }) => {

const ConnectedRouterWrapper = ({ children }) => (
    <Provider store={store}>
        <Router history={history}>{children}</Router>
    </Provider>
)

return ConnectedRouterWrapper

}

`gatsby-ssr.js`: ```import React from 'react'
import { Provider } from 'react-redux'
import { renderToString } from 'react-dom/server'

import createStore from './src/state/createStore'

export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
    const store = createStore()

    const ConnectedBody = () => (
        <Provider store={store}>
            {bodyComponent}
        </Provider>
    )
    replaceBodyHTMLString(renderToString(<ConnectedBody/>))
}
@kaumac kaumac changed the title Gatsby offline doesn't work with Redux Gatsby-plugin-offline doesn't work with Redux Aug 6, 2018
@kaumac kaumac added the type: bug An issue or pull request relating to a bug in Gatsby label Aug 6, 2018
@Chuloo Chuloo added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed type: bug An issue or pull request relating to a bug in Gatsby labels Aug 6, 2018
@tryzniak
Copy link
Contributor

tryzniak commented Aug 9, 2018

If I remove every mention of redux from the mentioned
https://github.com/gatsbyjs/gatsby/tree/master/examples/using-redux/ I still get strange offline behavior. The only page that works offline is the index one, others show 404.
Here a repo for your convenience https://github.com/tryzniak/gatsby-issue-7053 with removed redux/

@Chuloo Chuloo added type: bug An issue or pull request relating to a bug in Gatsby help wanted Issue with a clear description that the community can help with. and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants