mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-06-21 05:18:32 -06:00
PR-753737: Agregando primera version de service-worker.
This commit is contained in:
@ -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();
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
Reference in New Issue
Block a user