Skip to content

Instantly share code, notes, and snippets.

@rfischer20
Created January 4, 2016 03:16
Show Gist options
  • Save rfischer20/cea41504ae04ce1e6032 to your computer and use it in GitHub Desktop.
Save rfischer20/cea41504ae04ce1e6032 to your computer and use it in GitHub Desktop.
const SUBMIT_BUG = 'bugshift/SUBMIT_BUG';
const initialState = [];
export default function reducer(state = initialState, action = {}) {
const { type, payload } = action;
switch (type) {
case SUBMIT_BUG:
return [{
bugState: 'draft'
}, ...state];
default:
return state;
}
}
export function createBug(bug){
return {
type: SUBMIT_BUG,
payload: {
bugState: 'pending'
}
};
}
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as BugActions from '../redux/modules/bugform';
import { initialize } from 'redux-form';
import BugForm from '../components/BugForm';
class BugFormView extends Component {
handleSubmit(data){
console.warn(this);
console.warn(this.props);
this.props.dispatch(BugActions.createBug(data));
}
render() {
const { dispatch } = this.props;
console.warn('showing props');
console.warn(this.props);
//console.warn(bugState);
console.warn(BugActions);
console.warn(dispatch);
//const actions = bindActionCreators(BugActions, dispatch);
return (
<div>
<BugForm onSubmit={this.handleSubmit.bind(this)}/>
{'test'}
</div>
)
}
}
function mapStateToProps(state) {
return { bugState: state.bugState }
}
export default connect(mapStateToProps)(BugFormView)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment