1import React from 'react'
2import { render } from 'react-dom'
3import { Provider } from 'react-redux'
4import firebase from 'firebase/app'
5import 'firebase/auth'
6// import 'firebase/firestore' // <- needed if using firestore
7// import 'firebase/functions' // <- needed if using httpsCallable
8import { createStore, combineReducers, compose } from 'redux'
9import {
10 ReactReduxFirebaseProvider,
11 firebaseReducer
12} from 'react-redux-firebase'
13// import { createFirestoreInstance, firestoreReducer } from 'redux-firestore' // <- needed if using firestore
14
15const fbConfig = {}
16
17// react-redux-firebase config
18const rrfConfig = {
19 userProfile: 'users'
20 // useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
21}
22
23// Initialize firebase instance
24firebase.initializeApp(fbConfig)
25
26// Initialize other services on firebase instance
27// firebase.firestore() // <- needed if using firestore
28// firebase.functions() // <- needed if using httpsCallable
29
30// Add firebase to reducers
31const rootReducer = combineReducers({
32 firebase: firebaseReducer
33 // firestore: firestoreReducer // <- needed if using firestore
34})
35
36// Create store with reducers and initial state
37const initialState = {}
38const store = createStore(rootReducer, initialState)
39
40const rrfProps = {
41 firebase,
42 config: rrfConfig,
43 dispatch: store.dispatch
44 // createFirestoreInstance // <- needed if using firestore
45}
46
47// Setup react-redux so that connect HOC can be used
48function App() {
49 return (
50 <Provider store={store}>
51 <ReactReduxFirebaseProvider {...rrfProps}>
52 <Todos />
53 </ReactReduxFirebaseProvider>
54 </Provider>
55 )
56}
57
58render(<App />, document.getElementById('root'))
59