Skip to content

Instantly share code, notes, and snippets.

View MarcusHurney's full-sized avatar

Marcus Hurney MarcusHurney

View GitHub Profile
import { FETCH_TODOS } from '../actions/index';
const INITIAL_STATE = { all: [], todo: null};
export default function(state = INITIAL_STATE, action) {
switch(action.type) {
case FETCH_TODOS:
return {...state, all: action.payload.data };
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { fetchTodo, updateTodo } from '../actions/index';
import { Link } from 'react-router';
class ShowTodo extends Component {
static contextTypes = {
router: PropTypes.object
};
@MarcusHurney
MarcusHurney / gist:b9275e78aef232593e5e
Created February 27, 2016 12:40
The onChange handler functions do not get called when I make changes to the form.
import React, { Component, PropTypes } from 'react';
import { reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import LogoutHeader from './LogoutHeader';
import { fetchTodo, updateTodo, deleteTodo } from '../actions/index';
import { Link } from 'react-router';
class ShowTodo extends Component {
static contextTypes = {
@MarcusHurney
MarcusHurney / gist:35c4e6700ea86fc5d6f0
Created February 29, 2016 11:55
Having trouble with Redux Form
import React, { Component, PropTypes } from 'react';
import { reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import LogoutHeader from 'LogoutHeader';
import { fetchTodo, updateTodo, deleteTodo } from 'Actions';
import { Link } from 'react-router';
class ShowTodo extends Component {
static contextTypes = {
@MarcusHurney
MarcusHurney / gist:42f6a23b1d5515a667fe
Created March 1, 2016 14:14
Data flow for updating a todo item
// First handleSaveClick gets called from the ShowTodo Component
handleSaveClick: function () {
console.log("Handle Save Click Called!");
var props = {
title: this.state.todoTitle,
description: this.state.todoDescription
};
//This is from the login page submit handler, you can see I have success and error handlers
//Despite throwing an error, the page will still push onward to '/todos_index'
onSubmit(props) {
this.props.loginUser(props).then(() => {
this.context.router.push('/todos_index');
}, (response) => {
{
"name": "practice-todo-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
var Sequelize = require('sequelize');
var env = process.env.NODE_ENV || 'development';
var sequelize;
if (env === 'production') {
sequelize = new Sequelize(process.env.DATABASE_URL, {
dialect: 'postgres'
}); // This if statement should execute if the app is run on Heroku
} else {
sequelize = new Sequelize(undefined, undefined, undefined, {
{
"name": "practice-todo-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
import React, { Component } from 'react';
import { connect } from 'react-redux';
var Checkout = React.createClass({
render: function() {
return (
<div onClick={this.handleClick}>
<h1>{this.props.cart.length}</h1>
</div>