redux-fireuser
v0.0.1
Published
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Code Climate][climate-image]][climate-url] [![Code Coverage][coverage-i
Downloads
2
Maintainers
Readme
redux-fireuser
Redux middleware, actions, and reducers for Fireuser
Getting Started
Install through NPM
- Install:
npm install --save redux-fireuser
Documentation
Middleware
import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from '../reducers'; // Combined reducers
import thunkMiddleware from 'redux-thunk';
import { createMiddleware } from 'redux-fireuser';
let fireuserMiddleware = createMiddleware('testApp');
const createStoreWithMiddleware = compose(
// Save for redux middleware
applyMiddleware(thunkMiddleware, fireuserMiddleware)
)(createStore);
Reducers
import { combineReducers } from 'redux';
import { routerStateReducer } from 'redux-router';
import { Reducers } from 'redux-fireuser';
const rootReducer = combineReducers({
account: Reducers.account,
entities: Reducers.entities,
router: routerStateReducer
});
export default rootReducer;
Actions
import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Actions } from 'redux-fireuser';
class Main extends Component {
constructor(props) {
super(props);
}
onLoginClick = (e) => {
e.preventDefault()
this.props.login({username: 'test', password: 'asdfasdf'})
};
render() {
return (
<div className="App">
<button onClick={ this.onLoginClick }>Login</button>
</div>
)
}
}
// Place state of redux store into props of component
function mapStateToProps (state) {
return {
account: state.account
};
}
// Place action methods into props
function mapDispatchToProps (dispatch) {
return bindActionCreators(Actions, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(Main);