Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt integration with react-redux-firebase. #1

Open
wants to merge 1 commit into
base: merge_prs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
},
"jest": {
"preset": "react-native",
"setupFiles": ["<rootDir>/test/setup.js"],
"setupFiles": [
"<rootDir>/test/setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-navigation)"
]
Expand All @@ -45,6 +47,7 @@
"react-native-vector-icons": "^4.0.0",
"react-navigation": "^1.0.0-beta.6",
"react-redux": "^4.4.5",
"react-redux-firebase": "prescottprue/react-redux-firebase#react-native",
"redux": "^3.4.0",
"redux-logger": "^2.6.1",
"redux-loop-symbol-ponyfill": "^2.2.0",
Expand Down
7 changes: 6 additions & 1 deletion src/modules/counter/CounterViewContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import CounterView from './CounterView';
import {NavigationActions} from 'react-navigation';
import * as CounterStateActions from '../counter/CounterState';

import {firebaseConnect, dataToJS} from 'react-redux-firebase';
const CounterViewWithFirebase = firebaseConnect([
'/counter'
])(CounterView)

export default connect(
state => ({
counter: state.counter.value,
Expand All @@ -15,4 +20,4 @@ export default connect(
counterStateActions: bindActionCreators(CounterStateActions, dispatch)
};
}
)(CounterView);
)(CounterViewWithFirebase);
2 changes: 2 additions & 0 deletions src/redux/reducer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {loop, combineReducers} from 'redux-loop-symbol-ponyfill';
import {firebaseStateReducer} from 'react-redux-firebase'
import NavigatorStateReducer from '../modules/navigator/NavigatorState';
import CounterStateReducer from '../modules/counter/CounterState';
import SessionStateReducer, {RESET_STATE} from '../modules/session/SessionState';

const reducers = {
firebase: firebaseStateReducer,
// Counter sample app state. This can be removed in a live application
counter: CounterStateReducer,

Expand Down
23 changes: 20 additions & 3 deletions src/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {applyMiddleware, createStore, compose} from 'redux';
import * as reduxLoop from 'redux-loop-symbol-ponyfill';
import ReactNative from 'react-native';
import middleware from './middleware';
import reducer from './reducer';

Expand All @@ -18,11 +19,27 @@ const composeEnhancers = (__DEV__ && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__

const enhancer = composeEnhancers(...enhancers);

// create the store
// Firebase config
const firebaseConfig = {
apiKey: '',
authDomain: '',
databaseURL: ''
};

import { reactReduxFirebase } from 'react-redux-firebase';
const store = createStore(
reducer,
null,
enhancer
{ firebase: { authError: null } },
compose(
reactReduxFirebase(
firebaseConfig, {
userProfile: 'users',
enableRedirectHandling: false,
enableLogging: true,
rn: ReactNative
}),
enhancer,
)
);

export default store;