Browse Source

Redux está implementado. Creamos el store en App.js, nos connectamos a redux con connect en Home_page.js. Tenemos una sugeunda ruta de navegación Home a la que se accesa despues de que el usario está loggedIn. Esto está en el return de App.js. El store de redux es un provider de estado común a los componentes y envuelve el container de navegación.

ErnestoOrtiz2 3 years ago
parent
commit
04fa068b19
3 changed files with 3 additions and 28 deletions
  1. 3
    21
      App.js
  2. 0
    1
      redux/actions/index.js
  3. 0
    6
      redux/reducers/user.js

+ 3
- 21
App.js View File

@@ -14,20 +14,8 @@ import { Provider} from 'react-redux'
14 14
 import { createStore, applyMiddleware } from 'redux';
15 15
 import rootReducer from './redux/reducers'
16 16
 import thunk from 'redux-thunk'
17
-/*import { connect } from 'react-redux'
18
-import { bindActionCreators } from 'redux' 
19
-import { fetchUser } from './redux/actions/index'*/
20
-/*const seConfig = {
21
-  apiKey: "AIzaSyDW-ABAQ3r_WR7C7WC_3VprL77NcAoitJI",
22
-  authDomain: "freehand-d8ecd.firebaseapp.com",
23
-  projectId: "freehand-d8ecd",
24
-  storageBucket: "freehand-d8ecd.appspot.com",
25
-  messagingSenderId: "48371388186",
26
-  appId: "1:48371388186:web:9a5a4bf1218e17ac6326a3"
27
-};
28
-*/
29
-// Initialize Firebase
30
-//const app = firebase.initializeApp(seConfig);
17
+
18
+
31 19
 if (firebase.apps.length === 0) {
32 20
   firebase.initializeApp(firebaseConfig)
33 21
 }
@@ -96,10 +84,4 @@ export class App extends Component {
96 84
   }
97 85
 }
98 86
 
99
-export default App
100
-/*const mapStateToProps = (store) => ({
101
-  currentUser: store.userState.currentUser
102
-})
103
-const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch);
104
-
105
-export default connect(mapStateToProps, mapDispatchProps)(App);*/
87
+export default App

+ 0
- 1
redux/actions/index.js View File

@@ -1,7 +1,6 @@
1 1
 import { USER_STATE_CHANGE } from '../constants/index'
2 2
 import firebase from 'firebase'
3 3
 
4
-//Export to the app to trigger DB action
5 4
 export function fetchUser(){
6 5
     return((dispatch) => {
7 6
         firebase.firestore()

+ 0
- 6
redux/reducers/user.js View File

@@ -2,12 +2,6 @@ const initialState = {
2 2
     currentUser: null
3 3
 }
4 4
 
5
-//Action -an object describing what happened.
6
-//Reducers -calculate the new state based on the old state and the action
7
-//The state is equal to the initial state if no state is passed along to this f (an action is passed along the initial state)
8
-//Remember, our actions will be calling the DB, fetching data, and sending it to our reducer (this f)
9
-//which will then update the state. (Esto va a devolver al user con sus estado, nuevo o igual)
10
-//Esto esta setea'o para recivir info de otros files
11 5
 export const user = (state = initialState, action) => {
12 6
     return {
13 7
         ... state,