Skip to content

Instantly share code, notes, and snippets.

View timbuckley's full-sized avatar

Tim Buckley timbuckley

  • Aline
  • NYC
View GitHub Profile
@timbuckley
timbuckley / EmployeeList.js
Created December 19, 2016 03:43
Helping ppl on the internet
export class EmployeeList extends React.Component {
state = {
employees: [],
isLoading: true
}
componentDidMount() {
if (localStorage.token) {
this.loadEmployeesData()
}
// === Action Creators ===
export function posItemRequest(itemBody) {
return {
type: 'ITEM_POST_REQUEST',
payload: {
itemBody: itemBody
}
}
}
function itemsReducer(state, action) {
switch(action.type) {
case 'UPDATE_ITEM':
return state.items.map(i => itemReducer(i, action))
default:
return state
}
}
function itemReducer(state, action) {
We couldn’t find that file to show.
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Settings from '../components/scenes/settings'
import * as settingActions from '../actions/settings'
import * as signUpActions from '../actions/sign-up'
import * as loginActions from '../actions/login'
import * as routerActions from '../actions/router'
import React from 'react'
class AppTemplate extends React.Component {
componentWillMount() {
this.props.veritfyUserToken()
}
render() {
if (this.props.state.loading) {
return (
(defn flatten [nested]
(reduce
(fn [acc el]
(concat acc (if (sequential? el)
(flatten el)
[el])))
[]
nested))
@timbuckley
timbuckley / my-component.js
Created March 24, 2016 18:55
How to export/include a utility function.
import { percentage } from '../utils.js'
// Component goes here.