Created
November 1, 2020 01:34
-
-
Save neomatrixcode/bd17b38bec23f9b26208b71fb62fba07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import reportWebVitals from './reportWebVitals'; | |
import { createStore } from 'redux' | |
import rootReducer from './reducers' | |
import {agregarTarea} from './actions' | |
// Creamos el store al pasar el reducer raiz | |
const store = createStore(rootReducer) | |
// creamos nuestro creador de acciones fusionado llamado fusion_agregarTarea | |
const fusion_agregarTarea = tarea => store.dispatch(agregarTarea(tarea)) | |
// Mostramos el estado inicial | |
console.log(store.getState()) | |
// Cada vez que el estado cambie, lo mostramos | |
// Tenga en cuenta que subscribe() devuelve una función para anular el registro del listener | |
let unsubscribe = store.subscribe(() => | |
console.log(store.getState()) | |
) | |
// Enviamos algunas acciones | |
fusion_agregarTarea ("Tarea 1_fusionada"); | |
fusion_agregarTarea ("Tarea 2_fusionada"); | |
// Anulamos el monitoreo de las actualizaciones al estado | |
unsubscribe() | |
ReactDOM.render( | |
<React.StrictMode> | |
<App /> | |
</React.StrictMode>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment