Skip to content

Commit

Permalink
Set up store and react-redux-firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-phillips committed Aug 27, 2018
1 parent 232a3d2 commit c863c09
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -19,3 +19,5 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*

firebaseConfig.js
11 changes: 11 additions & 0 deletions src/redux/reducers.js
@@ -0,0 +1,11 @@
import { combineReducers } from 'redux'
import { firebaseReducer } from 'react-redux-firebase'
import { firestoreReducer } from 'redux-firestore'

export const initialState = {}


export const rootReducer = combineReducers({
firebase: firebaseReducer,
firestore: firestoreReducer,
})
39 changes: 39 additions & 0 deletions src/redux/store.js
@@ -0,0 +1,39 @@
import { createStore, compose } from 'redux'
import { reactReduxFirebase } from 'react-redux-firebase'
import { reduxFirestore } from 'redux-firestore'


import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

import firebaseConfig from '../firebaseConfig.js'
import { initialState, rootReducer } from './reducers'

firebase.initializeApp(firebaseConfig)
firebase.firestore().settings({ timestampsInSnapshots: true })

const enhancers = [
reduxFirestore(firebase),
reactReduxFirebase(firebase, {
userProfile: 'users',
useFirestoreForProfile: true,
}),
]

const reduxDevToolsExtension = window.devToolsExtension
if (
process.env.NODE_ENV === "development" &&
typeof reduxDevToolsExtension === "function"
) {
enhancers.push(reduxDevToolsExtension())
}

const composedEnhancers = compose(
...enhancers
)

const store = createStore(rootReducer, initialState, composedEnhancers)


export default store

0 comments on commit c863c09

Please sign in to comment.