Skip to content

Instantly share code, notes, and snippets.

:shipit:
Shipping stuff

Guilherme Oderdenge chiefGui

:shipit:
Shipping stuff
Block or report user

Report or block chiefGui

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View users.reducer.js
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,
View todos.reswitch.js
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)
View todos.js
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
}
}
View LightboxHome.jsx
import React from 'react'
class Lightbox extends Component {
constructor () {
super()
this.prev = this.prev.bind(this)
this.next = this.next.bind(this)
}
View Lightbox.jsx
import React from 'react'
const IMAGES = [1, 2, 3]
const Lightbox = ({imageUrl, onPrev, onNext}) => (
return (
<div>
<button onClick={onPrev}>Previous</button>
<img src={imageUrl} />
View Sidebar.jsx
import React from 'react'
import Dropdown from '../components/Dropdown'
const Sidebar = ({onClickRegisterButton}) => (
<aside>
<ul><li>Login</li></ul>
<ul><Dropdown onClickRegisterButton={onClickRegisterButton} /></ul>
</aside>
)
View Dropdown.jsx
import React from 'react'
const Dropdown = ({onClickRegisterButton}) => (
<ul>
<li>One</li>
<li onClick={onClickRegisterButton}>Two</li>
<li>Three</li>
</ul>
)
View Sidebar.jsx
import React from 'react'
const Sidebar = ({onClickRegisterButton}) => (
<aside>
<ul><li>Login</li></ul>
<ul><li onClick={onClickRegisterButton}>Register</li></ul>
</aside>
)
export default Sidebar
View Home.jsx
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)
View Home.demo.jsx
<Home>
<Header />
<Body>
<Sidebar />
<Content />
</Body>
<Footer />
</Home>
You can’t perform that action at this time.