Redux store enhancer that accepts configuration options and adds
store.firebase and store.firebaseAuth. Enhancers are most commonly placed in redux's compose
call
along side applyMiddleware.
Parameters
instance
otherConfig
Properties
firebaseInstance
Object Initiated firebase instance (can also be library following Firebase JS API such asreact-native-firebase
)config
Object Containing react-redux-firebase specific configurationconfig.userProfile
String Location on firebase to store user profilesconfig.enableLogging
Boolean Whether or not to enable Firebase database logging. Note: Only works if instance has enableLogging function.config.profileFactory
Function Factory for modifying how user profile is saved.config.presence
Boolean Location on Firebase to store currently online users list. Often set to'presence'
or'onlineUsers'
.config.sessions
Boolean Location on Firebase where user sessions are stored (only if presense is set). Often set to'sessions'
or'onlineUsers'
.config.updateProfileOnLogin
Boolean Whether or not to update profile when logging in. (default:false
)config.resetBeforeLogin
Boolean Whether or not to empty profile and auth state on loginconfig.enableRedirectHandling
Boolean Whether or not to enable auth redirect handling listener. (default:true
)config.onAuthStateChanged
Function Function run when auth state changes. Argument Pattern:(authData, firebase, dispatch)
config.enableEmptyAuthChanges
Boolean Whether or not to enable empty auth changes. When set to true,onAuthStateChanged
will be fired with, empty auth changes such as undefined on initialization. See #137 for more details. (default:false
)config.onRedirectResult
Function Function run when redirect result is returned. Argument Pattern:(authData, firebase, dispatch)
config.customAuthParameters
Object Object for setting which customAuthParameters are passed to external auth providers.config.profileFactory
Function Factory for modifying how user profile is saved.config.fileMetadataFactory
Function Factory for modifying how file meta data is written during file uploadsconfig.profileParamsToPopulate
(Array | String) Parameters within profile object to populate. As ofv2.0.0
data is only loaded for population, not actually automatically populated (allows access to both unpopulated and populated profile data).config.autoPopulateProfile
Boolean NOTE: Not yet enabled for v2.0.0. Whether or not to automatically populate profile with data loaded through profileParamsToPopulate config. (default:true
)config.setProfilePopulateResults
Boolean Whether or not to call SET actions for data that results from populating profile to redux under the data path. For example role parameter on profile populated from 'roles' root. True will call SET_PROFILE as well as a SET action with the role that is loaded (places it in data/roles). (default:false
)
Examples
Setup
import { createStore, compose } from 'redux'
import { reactReduxFirebase } from 'react-redux-firebase'
import * as firebase from 'firebase'
// React Redux Firebase Config
const config = {
userProfile: 'users', // saves user profiles to '/users' on Firebase
// here is where you place other config options
}
// initialize script from Firebase page
const fbConfg = {} // firebase config object
firebase.initializeApp(fbConfig)
// Add react-redux-firebase to compose
// Note: In full projects this will often be within createStore.js or store.js
const createStoreWithFirebase = compose(
reactReduxFirebase(firebase, config),
)(createStore)
// Use Function later to create store
const store = createStoreWithFirebase(rootReducer, initialState)
Returns Function That accepts a component and returns a Component which wraps the provided component (higher order component).