主要区别:
react-redux-firebase
- 用于将 Firebase 与 Redux 一起使用
react-native-firebase
- 用于使用带有 react-native 的 Firebase JS API
react-redux-firebase
实际上支持使用react-native-firebase
. react-native-firebase
在后台使用本机模块时提供Firebase JS API,这意味着您可以将其作为您的 Firebase 实例提供,如下react-redux-firebase
所示:
import { compose, createStore } from 'redux';
import RNFirebase from 'react-native-firebase';
import { getFirebase, reactReduxFirebase } from 'react-redux-firebase';
import thunk from 'redux-thunk';
import makeRootReducer from './reducers';
const reactNativeFirebaseConfig = {
debug: true
};
const reduxFirebaseConfig = {
userProfile: 'users', // save users profiles to 'users' collection
};
export default (initialState = { firebase: {} }) => {
// initialize firebase
const firebase = RNFirebase.initializeApp(reactNativeFirebaseConfig);
const store = createStore(
makeRootReducer(),
initialState,
compose(
reactReduxFirebase(firebase, reduxFirebaseConfig), // pass initialized react-native-firebase app instance
// applyMiddleware can be placed here
)
);
return store;
};
文档的 react-native recipes 部分介绍了此设置和更多内容。
免责声明:我是以下内容的作者之一react-redux-firebase