DEV Community

Discussion on: Showing "new version available" notification on create-react-app PWAs

Collapse
 
niketsoni profile image
Niket Soni

Hey Danielly, Thank you for this informative article. I have been following this article to convert my React app to PWA but when I am clicking on the refresh button I am getting an error.
Uncaught TypeError: e.postMessage is not a function.
Could you please help me with this?

Collapse
 
daniellycosta profile image
Danielly Costa

I'm so sorry not seeing your comment before... I think that maybe the setState function is not updating the state before calling the post message function ( reactjs.org/docs/state-and-lifecyc...).
Or if it's an old version, maybe the create-react-app doesn't create the service-worker file with postMessage function and you must configure the webpack configuration manually

Collapse
 
bakdakonusuruz profile image
Burak Bayraktaroglu

Check the state object that you save. If you are just saving "registration" object it will give you this error you should save "registration.waiting".
(That was my case, same error)