PR-753737: Agregando primera version de service-worker.

This commit is contained in:
2022-04-25 05:44:06 +00:00
parent 1a5ca4a6a4
commit e12e752a55
13 changed files with 1978 additions and 17 deletions

View File

@ -6,9 +6,11 @@ import { BrowserRouter as Router } from 'react-router-dom';
import { Provider } from 'react-redux';
import { IInitialState } from './reducers/index.js';
import setStore from './setStore.js';
import { config } from '../config';
import App from './components/App';
import './styles/global.sass';
import App from './components/App';
import serviceWorkerRegistration from '../serviceWorkerRegistration';
declare global {
interface Window {
@ -26,6 +28,8 @@ interface IHot {
accept: any
}
const { env } = config;
const preloadedState = window.__PRELOADED_STATE__;
const store = setStore({ initialState: preloadedState });
@ -57,6 +61,15 @@ hydrateRoot(container,
</Provider>
); */
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
//serviceWorker.register();
if((env) && (env === 'production')){
serviceWorkerRegistration();
}
if(module.hot){
module.hot.accept();
};
}

View File

@ -6,10 +6,10 @@ const initialState = {
hello: 'world'
};
let testReducer = (state = initialState, action: { type: any; payload: { hello: any; }; }) => {
const testReducer = (state = initialState, action: { type: any; payload: { hello: any; }; }) => {
switch (action.type){
case 'CHANGE_HELLO': {
let newHello = action.payload.hello;
const newHello = action.payload.hello;
return {
hello: newHello
};