Skip to content

Instantly share code, notes, and snippets.

View kylebuildsstuff's full-sized avatar

Kyle kylebuildsstuff

View GitHub Profile
...
import Datepicker from '../components/datepicker';
export const FormComponent = ({ handleSubmit, onSubmit, formValues, change }) => {
return (
<div className="flex flex-column justify-center items-center">
<h1>My Very own Form</h1>
<form
className="w-80"
onSubmit={handleSubmit(onSubmit)}
import React from 'react';
import moment from 'moment';
import { SingleDatePicker } from 'react-dates';
import 'react-dates/lib/css/_datepicker.css';
export class Datepicker extends React.Component {
constructor(props) {
super(props);
this.state = {
date: moment(),
import React from 'react';
import { Field } from 'redux-form';
import Text from '../components/text';
import Select from '../components/select';
import Radio from '../components/radio';
import Checkbox from '../components/checkbox';
export const FormComponent = ({ handleSubmit, onSubmit, formValues }) => {
return (
import React from 'react';
import { connect } from 'react-redux';
import { reduxForm, getFormValues } from 'redux-form';
import FormComponent from './form.component';
export const FormContainer = props => {
const submitForm = (formValues) => {
console.log('submitting Form: ', formValues);
}
...
<Field
name="wantsFries"
label="Would you like fries with that?"
component={Checkbox}
/>
...
import React from 'react';
export const Checkbox = props => {
return (
<div className="flex items-center mv4 w-100">
<input
{...props.input}
className="mr2"
type="checkbox"
checked={props.input.value}
// 4. Implement a function pipe() that takes several functions as arguments and returns a new
// function that will pass its argument to the first function, then pass the result to the second, then
// pass the result of the second to the third, and so on, finally returning the output of the last
// function. In other words, calling pipe(foo, bar, baz)(1, 2, 3) would be equivalent to
// calling baz(bar(foo(1,2,3))).
const pipe = (...fns) => {
return (
fns.reduce(
(a, b) => (...args) => b(a(...args))
@kylebuildsstuff
kylebuildsstuff / gist:f2972e6be4ae0a14012134019aa5f354
Last active July 7, 2017 18:39
Improve this React Component
// Improve this React Component
const JSON_URL = 'https://jsonplaceholder.typicode.com/comments';
class CommentList extends React.Component {
constructor() {
super();
this.state = {
comments: []
};
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
pass
from django.db import models
from users.models import User
class Todo(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=100, unique=True, blank=False, null=False)
user = models.ForeignKey('users.User', related_name='todos', on_delete=models.CASCADE, null=False)
class Meta: