Skip to content

Instantly share code, notes, and snippets.

View chiefGui's full-sized avatar
:shipit:
Shipping stuff

Guilherme Oderdenge chiefGui

:shipit:
Shipping stuff
View GitHub Profile
import reswitch from 'reswitch'
import {USERS_GET, USERS_GET__SUCCESS, USERS_GET__FAILURE} from 'consts/users'
const INITIAL_STATE = {areLoading: false, hasError: false, users: null}
const users(state = INITIAL_STATE, action) => reswitch(
USERS_GET,
{...defaultState, areLoading: true},
USERS_GET__SUCCESS,
const todos = (state = INITIAL_STATE, action) => reswitch(
ADD_TODO,
[...state.todos, action.todo],
REMOVE_TODO,
() => state.todos.filter(todo => todo.id !== action.todo.id)
)(state, action.type)
const todos = (state = INITIAL_STATE, action) => {
switch (action.type) {
case ADD_TODO:
return [...state.todos, action.todo]
case REMOVE_TODO:
return state.todos.filter(todo => todo.id !== action.todo.id)
default:
return state
}
}
import React from 'react'
class Lightbox extends Component {
constructor () {
super()
this.prev = this.prev.bind(this)
this.next = this.next.bind(this)
}
import React from 'react'
const IMAGES = [1, 2, 3]
const Lightbox = ({imageUrl, onPrev, onNext}) => (
return (
<div>
<button onClick={onPrev}>Previous</button>
<img src={imageUrl} />
import React from 'react'
import Dropdown from '../components/Dropdown'
const Sidebar = ({onClickRegisterButton}) => (
<aside>
<ul><li>Login</li></ul>
<ul><Dropdown onClickRegisterButton={onClickRegisterButton} /></ul>
</aside>
)
import React from 'react'
const Dropdown = ({onClickRegisterButton}) => (
<ul>
<li>One</li>
<li onClick={onClickRegisterButton}>Two</li>
<li>Three</li>
</ul>
)
import React from 'react'
const Sidebar = ({onClickRegisterButton}) => (
<aside>
<ul><li>Login</li></ul>
<ul><li onClick={onClickRegisterButton}>Register</li></ul>
</aside>
)
export default Sidebar
@chiefGui
chiefGui / Home.jsx
Last active February 22, 2017 15:37
import React, {Component} from 'react'
import {Header, Sidebar, Body, Content, Footer} from './containers'
import Modal from '../components/Modal'
class Home extends Component {
constructor () {
super()
this.openModal = this.openModal.bind(this)
<Home>
<Header />
<Body>
<Sidebar />
<Content />
</Body>
<Footer />
</Home>