Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//g.firestoreDB = firebase.firestore(); // can also use store.firebase.firestore()
let extraReducers = {
router: routerReducer,
};
let rootReducer = MakeRootReducer(extraReducers);
const store = createStore(
rootReducer,
initialState,
// Note: Compose applies functions from right to left: compose(f, g, h) = (...args)=>f(g(h(...args))).
// You can think of the earlier ones as "wrapping" and being able to "monitor" the ones after it, but (usually) telling them "you apply first, then I will".
compose(...[
//autoRehydrate({log: true}),
routerEnhancer,
applyMiddleware(...middleware),
reactReduxFirebase(firebase, reduxFirebaseConfig),
batchedSubscribe(unstable_batchedUpdates),
applyMiddleware(...lateMiddleware), // place late-middleware after reduxFirebase, so it can intercept all its dispatched events
g.devToolsExtension && g.devToolsExtension(reduxDevToolsConfig),
].filter(a=>a)) as StoreEnhancer
) as ProjectStore;
store.reducer = rootReducer;
function Dispatch_WithStack(action) {
if (g.actionStacks || (DEV && !actionStacks_actionTypeIgnorePatterns.Any(a=>action.type.startsWith(a)))) {
action["stack"] = new Error().stack.split("\n").slice(1); // add stack, so we can inspect in redux-devtools
}
store["dispatch_orig"](action);
}
if (store.dispatch != Dispatch_WithStack) {
store["dispatch_orig"] = store.dispatch;
store.dispatch = Dispatch_WithStack;
export default function configureStore(initialState, history) {
// Initialize Firebase instance
firebase.initializeApp(fbConfig)
const createStoreWithMiddleware = compose(
reactReduxFirebase(firebase, {
userProfile: 'users',
useFirestoreForProfile: true, // Store in Firestore instead of Real Time DB
enableLogging: false
})
)(createStore)
const store = createStoreWithMiddleware(rootReducer)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducer', () => {
const nextRootReducer = require('./reducer')
store.replaceReducer(nextRootReducer)
})
}
allowRegistration: false
};
// Set to localStorage
localStorage.setItem('settings', JSON.stringify(defaultSettings));
}
// Create initial state
const initialState = { settings: JSON.parse(localStorage.getItem('settings')) };
// Create store
const store = createStoreWithFirebase(
rootReducer,
initialState,
compose(
reactReduxFirebase(firebase),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
);
export default store;
// react-redux-firebase config
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
};
// Init firebase instance
firebase.initializeApp(firebaseConfig);
// Init firestore
const firestore = firebase.firestore();
const settings = { timestampsInSnapshots: true };
firestore.settings(settings);
// Add reactReduxFirebase enhancer when making store creator
const createStoreWithFirebase = compose(
reactReduxFirebase(firebase, rrfConfig), // firebase instance as first argument
reduxFirestore(firebase)
)(createStore);
const rootReducer = combineReducers({
firebase: firebaseReducer,
firestore: firestoreReducer,
notify: notifyReducer,
settings: settingsReducer
});
// Check for settings in localStorage
if (localStorage.getItem('settings') == null) {
// Default settings
const defaultSettings = {
disableBalanceOnAdd: true,
disableBalanceOnEdit: false,
export default function configureStore (initialState, history) {
const reduxRouterMiddleware = syncHistory(history)
const createStoreWithMiddleware = compose(
applyMiddleware(reduxRouterMiddleware),
reactReduxFirebase(fbConfig,
{
userProfile: 'users',
enableLogging: false
}
),
typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
)(createStore)
const store = createStoreWithMiddleware(rootReducer, initialState)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers')
store.replaceReducer(nextRootReducer)
})
}
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {createStore, applyMiddleware, compose} from 'redux'
import rootReducer from './components/redux/reducers/RootReducer';
import { Provider } from 'react-redux'
import rthunk from 'redux-thunk'
import {reactReduxFirebase, getFirebase} from 'react-redux-firebase'
import {reduxFirestore, getFirestore} from 'redux-firestore'
import config from './firebase/FirebaseConfig'
import 'semantic-ui-css/semantic.min.css'
const middleware = applyMiddleware(rthunk.withExtraArgument({getFirebase, getFirestore}))
const firebase = reactReduxFirebase(config, {useFirestoreForProfile:true, userProfile:'users', attachAuthIsReady: true});
const firestore = reduxFirestore(config)
const store = createStore(rootReducer, compose(middleware, firebase, firestore));
// ReactDOM.render(
//
//
// ,
// document.getElementById('root')
// );
store.firebaseAuthIsReady.then(() => {
ReactDOM.render(
,
document.getElementById('root')
);
firebase: firebaseReducer,
...reducers,
};
const defaultReducer = (s = {}) => s;
const AppReducers = combineReducers(
Object.keys(defaultStore).reduce((result, key) => {
return Object.assign({}, result, {
[key]: reducers[key] ? reducers[key] : defaultReducer,
});
}, reducerList),
);
const sagaMiddleware = createSagaMiddleware();
const createStoreWithFirebase = compose(
reactReduxFirebase(firebase, process.env.firebase),
composeWithDevTools(applyMiddleware(routerMiddleware(history), thunk, sagaMiddleware)),
)(createStore);
const rootReducer = reduceReducers(AppReducers, dataReducer);
const store = createStoreWithFirebase(connectRouter(history)(rootReducer), defaultStore);
sagaMiddleware.run(rootSaga);
export default store;
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from './store/reducers/rootReducer';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import fbConfig from './components/auth/config/fbConfig';
const store = createStore(rootReducer,
compose(
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
reduxFirestore(fbConfig),
reactReduxFirebase(fbConfig, {useFirestoreForProfile: true, userProfile: 'users', attachAuthIsReady: true})
)
);
store.firebaseAuthIsReady.then(() => {
ReactDOM.render(, document.getElementById('root'));
serviceWorker.unregister()
}
);
import firebase from './config/firebase';
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true,
}
const middlewares = [thunk.withExtraArgument({getFirebase, getFirestore})];
const middlewareEnhancer = applyMiddleware(...middlewares);
const storeEnhancers = [middlewareEnhancer];
export const store = createStore(
rootReducer,
composeWithDevTools(
...storeEnhancers,
reactReduxFirebase(firebase, rrfConfig),
reduxFirestore(firebase)
)
);
export default function configureStore (initialState, history) {
const createStoreWithMiddleware = compose(
reactReduxFirebase(fbConfig,
{
userProfile: 'users',
enableLogging: false
}
),
)(createStore)
const store = createStoreWithMiddleware(rootReducer, initialState)
return store
}