Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yashwanth2005-stack committed Nov 9, 2020
0 parents commit 45c2eb7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# flash-back

14 comments on commit 45c2eb7

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

dependencies

/node_modules
/.pnp
.pnp.js

testing

/coverage

production

/build

misc

.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

npm run build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
  "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
},
"history": {
  "version": "4.7.2",
  "resolved": "https://registry.npmjs.org/history/-/history-4.7.2.tgz",
  "integrity": "sha512-1zkBRWW6XweO0NBcjiphtVJVsIQ+SXF29z9DVkceeaSLVMFXHool+fdCZD4spDCfZJCILPILc3bm7Bc+HRi0nA==",
  "requires": {
    "invariant": "2.2.4",
    "loose-envify": "1.4.0",
    "resolve-pathname": "2.2.0",
    "value-equal": "0.4.0",
    "warning": "3.0.0"
  },
  "dependencies": {
    "warning": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
      "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
      "requires": {
        "loose-envify": "1.4.0"
      }
    }
  }
},
"hmac-drbg": {
  "version": "1.0.1",
  "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",

@@ -4660,6 +4682,11 @@
"minimalistic-crypto-utils": "1.0.1"
}
},
"hoist-non-react-statics": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
},
"home-or-tmp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz",
@@ -8394,6 +8421,33 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-4.0.1.tgz",
"integrity": "sha512-xXUbDAZkU08aAkjtUvldqbvI04ogv+a1XdHxvYuHPYKIVk/42BIOD0zSKTHAWV4+gDy3yGm283z2072rA2gdtw=="
},
"react-router": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz",
"integrity": "sha512-yrvL8AogDh2X42Dt9iknk4wF4V8bWREPirFfS9gLU1huk6qK41sg7Z/1S81jjTrGHxa3B8R3J6xIkDAA6CVarg==",
"requires": {
"history": "4.7.2",
"hoist-non-react-statics": "2.5.5",
"invariant": "2.2.4",
"loose-envify": "1.4.0",
"path-to-regexp": "1.7.0",
"prop-types": "15.6.2",
"warning": "4.0.2"
}
},
"react-router-dom": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-4.3.1.tgz",
"integrity": "sha512-c/MlywfxDdCp7EnB7YfPMOfMD3tOtIjrQlj/CKfNMBxdmpJP8xcz5P/UAFn3JbnQCNUxsHyVVqllF9LhgVyFCA==",
"requires": {
"history": "4.7.2",
"invariant": "2.2.4",
"loose-envify": "1.4.0",
"prop-types": "15.6.2",
"react-router": "4.3.1",
"warning": "4.0.2"
}
},
"react-scripts": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.1.5.tgz",
@@ -8786,6 +8840,11 @@
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz",
"integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY="
},
"resolve-pathname": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.2.0.tgz",
"integrity": "sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg=="
},
"resolve-url": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
@@ -10139,6 +10198,11 @@
"spdx-expression-parse": "3.0.0"
}
},
"value-equal": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/value-equal/-/value-equal-0.4.0.tgz",
"integrity": "sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw=="
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -10175,6 +10239,14 @@
"makeerror": "1.0.11"
}
},
"warning": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.2.tgz",
"integrity": "sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==",
"requires": {
"loose-envify": "1.4.0"
}
},
"watch": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/watch/-/watch-0.10.0.tgz",

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
"name": "flash-back",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.1",
"@testing-library/user-event": "^12.2.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

� � �� � ã� F �� � � )� � 9� 5� @@ � °� n� ‰PNG

IHDR � ��� (-�S äPLTE""""""""""""""""""2PX=r€)7;*:>H�¤-BGEˆš8do5Xb6[eK™®Kš¯1MU9gs3S\I“§:gt'03@{‹V¹ÔT´ÏA}�V»Ö@y‰6\fH’¦-CII”¨Eˆ›+;@7_i7_jFŠ�J–«K›°H�£-BHaÚû,@fcƒ”L�³&.0W½ÙN£ºI“¨$)+B�‘J•ªR¯È?v†>s�>u„S±Ê=q�P©ÁP¨ÀP§¿,?D4U^%+-M ¶K˜®%+,2OX+<ALœ²#&&D†˜%,.I•©vôTö �tRNSIæçJäeÀe¦ ©IDATx�MŽµZEA „ÿÙ³ îî%R¡ïßáTThÇG…»,Á®Å=�²�Ò�îmífímnf’A–$â‡>!�¦gºôHg½�Eß�ܵ}� �Ý»ý‡º¼k�d�ú§¯Jo�—™Î3æL"J¹ ›ÌÕüQ‡$âçļ�ffµ,é€5i9��ÌŸ¯H¨�/mB�†‡wÍÜw;D
Ø+&‚W«�ª¹¨Dôo�@Ê´RI©ÐB¡om�.�Û³�À IEND®B`‚‰PNG

IHDR � ��� שÍÊ �ePLTE""""""""""""""""""""""""2RZN¢¹J–«3R[J—¬)59YÁÞ0KS4WQ«ÄLœ²%+-0JR)6::gtC‚“"##?v†U·Ñ?w†<n{&-/YÂß=q�:iuB��A}�A{ŒB�‘/IPP§¿=q€K™®_ÔóL�³$();lzR¯ÉaÚûI“¨ZÆã3U^1MU3T]ZÅâI“§X¿ÜF‹ž-BGP¨À6[e,@E5ZdO§¿-BHX¿Û+=AW¾Ú,@FW¼ØQªÃ?v…W¼×+<A@yˆ"#$\Ìê4Wa\ÌëS²Ì$(*.EL^ÑñVºÕ6]h#$%GŽ¡#&';jwV¹Ô-CIL›±ZÄá^Ðï>u„S°Ê/HNM ·_Õõ\ËéM ¶8doD…—D†˜>tƒ+=B[Èæ,>C>t‚<o}@y‰0LS.EKT´Î$'(%,.A~ŽW½ÙC�’%+,\ÊèC!ä� �tRNS�‘íî�ˆ‰œG¾Ö �OIDATx�l‰ÃB¶Q�…Ÿu´ß_ȳ<Ë�¦Ýv�e�ê�²�óa�6�AξŒ��ûv¢{�@Î� E' Þd IÕ!ç�ží� ðC—ÔT‹�þg � 1ÂE(Ï��ñSQs�âi Ä�…Zÿ·�V�¹� �Ð)ég!‰ªhÎù��t�éº-i}˜µ�µ<Õ?�¶�lBZaÄ´4{DÓ⌻_e8¥yÇ�­À�3ž)Ÿ¥?°f;8.ã�¤tÌ=å;� :ã52f�KZì�l�ù¨ØšÍ9.ž#ƒÒ�AÁqÌúÛ���®£Vÿ�=��$¬Â?_¶¾®�ÔqMç�.ïJ$�
?^q÷ñíÛ�ï.},‚ìsæÝ _TttÔ¾ �1#�‰/(ì—-[���è�èÌ�ÚïÅðZ�d5’Ž™›?ÎebZ¿Þˆi.Ûæ™ ��ìq΄+1°�}ÂŒ5ù ïçd¨G•Ïø IEND®B`‚‰PNG

IHDR �� D¤ŠÆ �APLTE """""""""""""""""""""""""""2RZVºÖ_ÔôU·Ñ=r€$()'25]ÎíCƒ•0LS<o}XÀÜX¿Û0JQ=pD„–<n{VºÕE‡™8do_ÔóEˆšF‹žH‘¥9dp_ÕõH�¤I“¨FŒŸ6[eÖ÷×øL�³/GM_ÓòU¸Ó'02P©Á/IPPªÂX¿Ü&/1;ly3R[ØøGŽ¡T³Í\ÌêaÚû1OW"##Q«ÄaÙúR®Ç=q€Öö.EL+=ATµÐ-CIK˜®#&'C‚“^ÐïI”¨&.04U^^Ñð@yˆZÇä$(*[Éç^Ññ,?DR¯É"#$1NV1MTD…—>u„;kxG� R¯È/HN&-/@y‰>s�>t‚@zŠ]ÍìP¨À$'(D†—]Ïî<n|0JRU·Ò�×\¼ tRNS %­ñ'ïó(òÑÝè �žIDATx��“�šC1�F_Ý¿MmÛ¶4¶m{ÿ�˜¤n†çáÓ ®�A$–à�$b‘ Heø�™T�ãWÄÂh�•šh´:PtZ
Q«0@.€Þ4™-V�³Zì&‡A��#ÁébkÝÄãñúØ>.''ø��C$�FØÏ ‘(�±x"6X�á�c�”TÚéL§@i�ù;d d-¹|¾P,�È”9¡R­Õ�Íf3�¢¿F½VmM�íX§ÚíÍ�ç�@y˜7ÎõºÕN¬=��— ŽåÈʪu
}Ö¬«+‘e‡aiq ¤Ö76�­í�Ý=h
ûZìíî�l�›�ë‡}á¨�ʱ¥[F«I9A¹k9�¥Öë�ä�Œ3¢Ã9�Ρóž�qBØáb¸ÃåU_¸^�Ü [�·ô�w†ý{z‡�v‡�z‡Ù(Š£(Š£(þ›�†Šfòq”ÉG–Éïkñ”ÏçŠY¾�ÿªfäòÇà:*4ÓQ\O>Ÿ‘ ‡¼<�דúW£éÍZ|�Þ‹Å7“ñ•ïjTÔäãn�”½»�¢®$Hð+ò¿GOñûð*èx‹•ø�¥X*|�”�^ÿ��d� IEND®B‚‰PNG

IHDR @ @�� �·�ì �:PLTE """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""%+-@y‰W¼××ø^ÑñS²ÌC‚“,>C*8<XÁÝaÚûaÙùMŸµ+<AaÙúXÀÜ#%%TµÐLž´=q�>u„K›°ÖöA}�L›±8do=r€%+,@yˆ^ÐïS²Ë)59=q€P©ÁU·Ò"#$PªÂ\Êè0JQQªÃ"##U·Ñ#&&Ôô>t‚>s�Øø_Ôó5Yc1OW5Zd1NV+=B1MU+;@/GM\Ìê*;?3S\)8<2RZ_Õõ+=A]Ïî,@F,@E&-/0KS7alO¦¾9dp8amB~�EˆšP¨ÀN¢¹'023T]]Îí?x‡3U^Cƒ•6\gU¸Ó&.0D„–7_iR­ÆH‘¥I”¨M ¶$(*?v…ZÆãX¿Ü-AG#$%[Éç8co[ÈæW½ÙC�’'25?v†8bn%*+Lœ²N£º2PX)7;=p~(58^ÒòP§¿4WaQ«ÄT´Ï0JRQ¬ÅT´ÎI“¨6]hR¯ÉT³Í0LSF‹�9eqEˆ›E‰œ9gsFŠ�Cƒ”#&'\ËéÖ÷&/16\fB�‘A{ŒR®Ç]Íì(47%,.:>9=9fr:gt7^iU¶Ð?w†ZÇäX¿Û^ÑðQ­ÅH�£)6:V¹Ô'034U^E‡™.EL.FMK™®@zŠS×�� �tRNS Ž×øÖ�”ý˜ »½•+ü�ùóÔ�,ØúôÀ=V� � IDATx�¤Ëµ�C! �Ð‡C|ÿ�ãÚ�^yR]ÕMÛáO]ßÔÕÝ0NÈ2ÍËí¿"��ªª¢(0V�ã(ÀY%PDT-(m¬ó!âK ÞY£�´•üIÒf{³Û�Þáa�¼§§ô3—ÕOp&”�Ф‰¡ xŽ÷#Ÿj­ôÚ¶m�méòc)]m¤’‡É)Ƨgfç�hk²ñÎÒ ægg¦Ç™šì�Ð+X€Åêuiy�Vת·k«°²[ü:,Ø�6ØÜjIJ
;»"»;°×Xùþ�ÛfÁá�ÇÍûý“SÎÎÏÏ8=Þo¾;æèÐ(�ƒ‹öÓ¥BkÔeûÍ�\��7p+mîîáþNÚ<À�Qð�OÒæù�ô³´y‚g»�ttÐë�o•ý½£ŸìVð�»Òäs�ýü¬™ø”&_ða�ü�ïV�~à·Ö�?­
8à�Q ;8¥Á,¸¤‚�f¥�“�1�Üx¤†×§ñŸ�
œøÑA¯Ôð°a#�±³�¶¦#ŠnP‘i+¼¶CÈ,ˆÆèäÍ_á�NbÑá‚øç� •HŽB
ÚÒ¦ �L( ^<ñÃ�‚L6�pJ¾P”É�¥Ž©¢%"“R,ä9�Èe3eRËa1�(
¢ßqÇ8ÙŽ´ŠmK˱mƶmÛü·yi!è�ΪYÏuë ÀÏ_Àï?i÷ˆý+ò�ŠÄA�|�ù{‘˜´?¿�_En�).�JËD¤<€
©¬¢Z\Ts©R*�(� ¯©�JŠ��…u�X/�
4J�9š¡5·DEµ4kÇ4‡&i¥V4Ú�¡®Ð��¯†vsf:àg,�¢èBC»î$¶�ºÍùî�‡á–@�ôŠI
?�<��‘! ^ŠÈàÓ½ÇöäõB‘%�Làw±��FD1ŠÁ¨(F€�±ø�H˜%0Æ�±�¿ÅØ„(¢0ˆ�ÅÄ��'Åæ�—N.0u„@íY‡P�WìIüaNâK š�™Ä?ðÓµŒ=Žeœv/c—±ŒÓ0c�0÷2Êë:ˆ06R-uÒÄ­\Q̶ää´¼µ6R#
ÆFš³6Òñ·rÕ�­ìu˜æ�mâðÂ�ž‡Iñi~� –Åü Ã�sPþ"± �óŸ¼
eiyå£ËPšàãÊò’§¡œÝÒ,S]U¦ºV…�ªÖ”©®Z¦êoëë�·xzã™âÆSnm¬{ÚºwaÙ„Ï�…Å»´Ýõ(mg/®þå½À¿¼û�Œ[§���b³µ�q¶Å&Õ¯�¹�$�ñzÈŠ�‹�H>aÌKT1/æø1O‚‰0¾.�h�͇YþAÓö£
-ê>Û‹º«¢XÕ¢î}ߨë ÛÑ;�ÃöN´�ØvÅý�θÿ1 �ë×ÄO@&v/Äþ_—ö\ô�Ç\í.�™½+0”�;���!�fÊ �¦´Ó% JY·O”ÂŽ'/Å]_Š;ß�À'"&Nªn a�Q�^ �”cx¦AáÒ IEND®B`‚

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No description provided.

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@Keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import logo from './logo.svg';
import './App.css';

function App() {
return (



logo


Edit src/App.js and save to reload.



Learn React



);
}

export default App;

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render();
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
import AddSusbscriber from './AddSubscriber';
import './common/common.css';
import PhoneDirectory from './PhoneDirectory';

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No description provided.

@yashwanth2005-stack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// In production, we register a service worker to serve assets from local cache.

// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.

// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.

const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);

export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see facebook/create-react-app#2374
return;
}

window.addEventListener('load', () => {
  const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;

  if (isLocalhost) {
    // This is running on localhost. Lets check if a service worker still exists or not.
    checkValidServiceWorker(swUrl);

    // Add some additional logging to localhost, pointing developers to the
    // service worker/PWA documentation.
    navigator.serviceWorker.ready.then(() => {
      console.log(
        'This web app is being served cache-first by a service ' +
          'worker. To learn more, visit https://goo.gl/SC7cgQ'
      );
    });
  } else {
    // Is not local host. Just register service worker
    registerValidSW(swUrl);
  }
});

}
}

function registerValidSW(swUrl) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log('New content is available; please refresh.');
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}

function checkValidServiceWorker(swUrl) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
if (
response.status === 404 ||
response.headers.get('content-type').indexOf('javascript') === -1
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

Please sign in to comment.