All I needed to do was adding this line to .bash_profile // .zshrc export PATH="$PATH":~/.node/bin
Add this line to .bashrc // .zshrc export PATH="$HOME/npm/bin:$PATH"
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { createStore } from 'redux'; | |
| // Preparamos nuestra funcion reducer | |
| const myReducer = (state = 0, action) => { | |
| switch(action.type) { | |
| case 'sumar': | |
| return state + 1; | |
| case 'restar': |
| // Reducer - Función Pura | |
| // Usando es6 | |
| // Nunca cambiamos el state | |
| // Devolvemos 0 si el state es undefined | |
| // Devolvemos el state si no conocemos el action | |
| const myReducer = (state = 0, action) => { | |
| switch(action.type) { | |
| case 'sumar': | |
| return state + 1; |
| // Funcion Pura | |
| function doble(num) { | |
| return num * 2; // No modifica el argumento. | |
| } | |
| function doblarLista(listado){ | |
| // Retorna un nuevo listado sin modificar nada. | |
| return listado.map(doble); | |
| } |
| // El metodo recive las propiedades previas y el estado previo. | |
| componentDidUpdate: function(prev_props, prev_state) {} |
| // Ecmascript 5 | |
| var MyComponent = React.createClass({ | |
| shouldComponentUpdate: function(next_props, next_state) { | |
| return false; | |
| } | |
| // Despues del primer render, nunca volver a renderizarse. | |
| render: function() { | |
| <div>Soy un component</div> |
| // Ecmascript 5 | |
| var MyComponent = React.createClass({ | |
| componentWillReceiveProps: function(next_props){ | |
| this.setState({ loading: true }); | |
| }, | |
| render: function() { | |
| className = this.state.loading ? 'loading' : 'loaded'; | |
| return(<div className={className}>Soy un component</div>) |
| // Ecmascript 5 | |
| var MyComponent = React.createClass({ | |
| componentWillMount: function() { | |
| console.log('El componente aun no está disponible en el DOM'); | |
| return { data:[] }; | |
| }, | |
| componentDidMount: function() { | |
| console.log('El componente está disponible en el DOM'); |
| // Ecmascript 5 | |
| var MyComponent = React.createClass({ | |
| componentWillMount: function() {} | |
| console.log('El componente aun no está disponible en el DOM'); | |
| return { data:[] }; | |
| }, | |
| render: function() { | |
| <div>Soy un component</div> | |
| } | |
| }); |
| npm ls --depth 0 -g |