mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-12 13:36:43 +00:00
install firestore
This commit is contained in:
parent
2b1bd46268
commit
0196ab4b9a
5 changed files with 45 additions and 6 deletions
|
|
@ -28,6 +28,7 @@
|
|||
"react-redux-firebase": "^3.4.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "3.4.1",
|
||||
"redux-firestore": "^0.13.0",
|
||||
"typescript": "~3.7.2"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//Firebase
|
||||
import firebase from 'firebase/app';
|
||||
import 'firebase/auth';
|
||||
import 'firebase/firestore';
|
||||
|
||||
const CONFIG = {
|
||||
apiKey: process.env.REACT_APP_API_KEY,
|
||||
|
|
@ -13,7 +14,8 @@ const CONFIG = {
|
|||
measurementId: process.env.REACT_APP_MEASUREMENT_ID,
|
||||
};
|
||||
|
||||
// initialize firebase
|
||||
// initialize firebase services
|
||||
firebase.initializeApp(CONFIG);
|
||||
firebase.firestore();
|
||||
|
||||
export default firebase;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
// Redux
|
||||
import {createFirestoreInstance} from 'redux-firestore';
|
||||
import store from '..';
|
||||
// Firebase
|
||||
import firebase from '../../services/firebase';
|
||||
// Typing
|
||||
import Dev from '../../models/Dev';
|
||||
|
||||
// react-redux-firebase config
|
||||
const RRF_CONFIG = {
|
||||
// userProfile: 'users'
|
||||
userProfile: 'users',
|
||||
useFirestoreForProfile: true,
|
||||
};
|
||||
// object required by RRFProvider
|
||||
const rrfProps = {
|
||||
firebase,
|
||||
config: RRF_CONFIG,
|
||||
dispatch: store.dispatch,
|
||||
createFirestoreInstance,
|
||||
};
|
||||
|
||||
// Firestore SChema
|
||||
export interface Schema {
|
||||
devs: Dev;
|
||||
}
|
||||
|
||||
export default rrfProps;
|
||||
|
|
|
|||
|
|
@ -2,19 +2,26 @@
|
|||
import {configureStore} from '@reduxjs/toolkit';
|
||||
import authReducer from './auth/';
|
||||
// Firebase
|
||||
import {firebaseReducer, FirebaseReducer} from 'react-redux-firebase';
|
||||
import {
|
||||
firebaseReducer,
|
||||
FirebaseReducer,
|
||||
firestoreReducer,
|
||||
} from 'react-redux-firebase';
|
||||
// Typing
|
||||
import User from '../models/User';
|
||||
import {Schema} from './firebase/config';
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
// auth: authReducer,
|
||||
firebase: firebaseReducer,
|
||||
firestore: firestoreReducer,
|
||||
},
|
||||
});
|
||||
|
||||
// State type
|
||||
export interface RootState {
|
||||
firebase: FirebaseReducer.Reducer;
|
||||
firebase: FirebaseReducer.Reducer<User, Schema>;
|
||||
}
|
||||
// export type RootState = ReturnType<typeof store.getState>;
|
||||
|
||||
export default store;
|
||||
|
|
|
|||
19
yarn.lock
19
yarn.lock
|
|
@ -5921,6 +5921,11 @@ immer@1.10.0:
|
|||
resolved "https://registry.yarnpkg.com/immer/-/immer-1.10.0.tgz#bad67605ba9c810275d91e1c2a47d4582e98286d"
|
||||
integrity sha512-O3sR1/opvCDGLEVcvrGTMtLac8GJ5IwZC4puPrLuRj3l7ICKvkmA0vGuU9OW8mV9WIBRnaxp5GJh9IEAaNOoYg==
|
||||
|
||||
immer@5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/immer/-/immer-5.0.0.tgz#07f462b7d95f7e86c214a861ecacd766d42b8c0a"
|
||||
integrity sha512-G7gRqKbi9NE025XVyqyTV98dxUOtdKvu/P1QRaVZfA55aEcXgjbxPdm+TlWdcSMNPKijlaHNz61DGPyelouRlA==
|
||||
|
||||
immer@^6.0.1:
|
||||
version "6.0.5"
|
||||
resolved "https://registry.yarnpkg.com/immer/-/immer-6.0.5.tgz#77187d13b71c6cee40dde3b8e87a50a7a636d630"
|
||||
|
|
@ -9770,6 +9775,20 @@ redent@^3.0.0:
|
|||
indent-string "^4.0.0"
|
||||
strip-indent "^3.0.0"
|
||||
|
||||
reduce-reducers@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/reduce-reducers/-/reduce-reducers-1.0.4.tgz#fb77e751a9eb0201760ac5a605ca8c9c2d0537f8"
|
||||
integrity sha512-Mb2WZ2bJF597exiqX7owBzrqJ74DHLK3yOQjCyPAaNifRncE8OD0wFIuoMhXxTnHK07+8zZ2SJEKy/qtiyR7vw==
|
||||
|
||||
redux-firestore@^0.13.0:
|
||||
version "0.13.0"
|
||||
resolved "https://registry.yarnpkg.com/redux-firestore/-/redux-firestore-0.13.0.tgz#154e705726740c6173e2f8a1d82214aeccc6954f"
|
||||
integrity sha512-0Vf/MXrH6gUqVwSmAQAz9Ic1J4uADCaF29DcpcNU2ecZoYG5aQSZO2iGXUqzjAOeatE1Ksz8SDEvKu8gBRvYXg==
|
||||
dependencies:
|
||||
immer "5.0.0"
|
||||
lodash "^4.17.15"
|
||||
reduce-reducers "^1.0.4"
|
||||
|
||||
redux-thunk@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
||||
|
|
|
|||
Loading…
Reference in a new issue