Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
View GitHub Profile
@codemilli
codemilli / reducers.js
Created February 12, 2016 14:06
2 type of reducer.
function visibilityFilter(state = 'SHOW_ALL', action) {
switch (action.type) {
case 'SET_VISIBILITY_FILTER':
return action.filter;
default:
return state;
}
}
function todos(state = [], action) {
@codemilli
codemilli / todos.js
Last active February 21, 2016 04:13
todos 를 rendering 하는 컴포넌트
import React, { PropTypes } from 'react';
/**
* Define React Presentational Component Todos
*/
const Todos = ({todos, onToggle }) => {
return (
<ul>
{todos.map((todo) => (
<li
@codemilli
codemilli / header.js
Created February 12, 2016 14:37
visible option 을 선택하는 header component
import React, { PropTypes } from 'react';
/**
* Define React Presentational Component Header
*/
const Header = ({visible, setVisible}) => {
const getStyle = (type) => {
if (visible === type) {
return {
textDecoration: 'underline'
@codemilli
codemilli / app.js
Last active February 21, 2016 04:29
component 들을 redux 와 연결하는 app container
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as ActionCreators from '../actions';
import Add from '../components/add';
import Todos from '../components/todos';
import Header from '../components/header';
export default function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers)
var finalReducers = {}
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i]
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key]
}
}
var finalReducerKeys = Object.keys(finalReducers)
@codemilli
codemilli / introrx.md
Created February 28, 2016 10:42 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
class Rational(x: Int, y: Int) {
require(y != 0, "denominator must be nonzero");
def this(x: Int) = this(x, 1)
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
private val g = gcd(x, y)
def numer = x / g
def denom = y / g
class Rational(n: Int, d: Int) {
require(d != 0)
private val g = gcd(n.abs, d.abs)
val number = n /g
val denom = d / g
def this (n: Int) = this(n, 1)
def + (that: Rational): Rational =
if (true) {
var a = 'hacker';
let b = 'moon';
console.log('a => ', a); // hacker
console.log('b => ', b); // moon
}
console.log('a => ', a); // hacker
console.log('b => ', b); // b is not defined