Skip to content

Instantly share code, notes, and snippets.

View rafaellucio's full-sized avatar
🏠
Working from home

png rafaellucio

🏠
Working from home
View GitHub Profile
@rafaellucio
rafaellucio / gist:b96fb988854179b2a75e5761862956c6
Created December 9, 2017 22:58 — forked from ramnathv/gist:2272049
Shell Script to Display Directory Structure
#!/bin/sh
#######################################################
# UNIX TREE #
# Version: 2.3 #
# File: ~/apps/tree/tree.sh #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
# in a single command to show the nesting of #
import React, { Component } from 'react'
export default class Counter extends Component {
increment = () => {
this.props.dispatch({ type: 'INCREMENT' });
}
decrement = () => {
this.props.dispatch({ type: 'DECREMENT' });
}
function brokenReducer(state = initialState, action) {
switch(action.type) {
case 'INCREMENT':
// NO! BAD: this is changing state!
state.count++;
return state;
case 'DECREMENT':
// NO! BAD: this is changing state too!
state.count--;
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
const initialState = {
count: 0
}
function reducer(state = initialState, action) {
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
const initialState = {
count: 0
};
function reducer(state = initialState, action) {
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
const initialState = {
count: 0
};
function reducer(state = initialState, action) {
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
function reducer(state, action) {
return {
count: 42
}
}
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
function reducer() {
return {
count: 42
}
}
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import CounterContainer from './Counter.container'
function reducer() {}
const store = createStore(reducer)
const App = () => (
import { Provider } from 'react-redux';
...
const App = () => (
<Provider>
<CounterContainer />
</Provider>
);