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
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) {
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, { Component } from 'react'
export default class Counter extends Component {
increment = () => {
this.props.dispatch({ type: 'INCREMENT' });
}
decrement = () => {
this.props.dispatch({ type: 'DECREMENT' });
}
@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 #
@rafaellucio
rafaellucio / README.md
Last active August 14, 2024 17:33
Plugin NVM oh-my-zsh

NVM plugin

Description

This plugin provides load nvm if it exists and when the .nvmrc file exists in your directory, it will download the described node version.

To start using it:

  • Add the ZSH_NVM_AUTOLOAD=true at the beginning of the file ~/.zshrc
  • Add nvm plugin to your plugins array in ~/.zshrc
import React from 'react'
const Counter = props => (
<div>
<h2>Counter</h2>
<div>
<button onClick={props.decrement}>-</button>
<span>{props.count}</span>
<button onClick={props.increment}>+</button>
</div>
import { connect } from 'react-redux'
import Counter from './Counter'
const mapStateToProps = state => ({ count: state.count })
const mapDispatchToProps = dispatch => ({
increment: () => dispatch({ type: 'INCREMENT' }),
decrement: () => dispatch({ type: 'DECREMENT' })
})
class Logger {
sucesso(message) {
console.log(`SUCESSO: ${message}`)
}
error(message) {
console.error(`ERROR: ${message}`)
}
}