create-react-app service worker issue. #9663
Unanswered
DhilipThangaraj
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey guys,
My project is basically react with redux based application. as we know,react application generally have the service worker enabling/disabling mechanism in src/index.js
serviceWorker.register()/serviceWorker.unregister()
at the creating time, so that will have the ability to turn our application with PWA support.Our project came with the approach recently ,we had to control the
serviceWorker.register()/serviceWorker.unregister()
by some server config property, so when we hit our application at first time we get the server config aspwaEnabled: true
that i was keeping in the redux state and trying to control theserviceWorker.register()/serviceWorker.unregister()
in index.js.For some reason, my service worker was not getting registered properly ,i went ahead and kept some console logs statements inside the
src/serviceWorker.js
then i got to know thatwindow.addEventListener("load", () => {})
somehow was not getting called so only sw registration not happened .whereas if i was not controlling by any conditionsserviceWorker.register()/serviceWorker.unregister()
in index.js would just works fine and able to get access of PWA..Here if anybody help on this why am not able to control the serviceworker registration function by condition, that would be great.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions