Button.js
import { connect, actions } from 'mirrorx'
const Button = ({value, handleClick}) => (
<button onClick={handleClick}>
{value}
const incrementAsync = (count) => async (dispatch) => { | |
await delay() | |
dispatch(increment(count)) | |
} |
const countReducer = { | |
INCREMENT: (state, action) => state + action.payload, | |
DECREMENT: (state, action) => state - action.payload, | |
} |
const countReducer = (state, action) => { | |
switch(action.type) { | |
case INCREMENT: | |
return state + action.payload | |
case DECREMENT: | |
return state - action.payload | |
default: | |
return state | |
} | |
} |
const increment = (count) => ({ type: 'INCREMENT', payload: count }) | |
const decrement = (count) => ({ type: 'DECREMENT', payload: count }) |
const store = new Redux.Store({ | |
initialState: {}, | |
reducers: { count }, | |
middlewares: [api, devTools], | |
}) |
import { createStore, applyMiddleware, compose } from 'redux' | |
import thunk from 'redux-thunk' | |
import api from '../middleware/api' | |
import rootReducer from '../reducers' | |
import DevTools from '../containers/DevTools' | |
const store = (preloadedState) => { | |
return createStore( | |
rootReducer, | |
preloadedState, |
class Store { | |
constructor(reducers = {}, initialState = {}, middleware = []) { | |
this.state = initialState | |
this.reducers = reducers | |
this.subscriptions = [] | |
this.middlewares = middlewares | |
} | |
getState() { | |
return this.state | |
} |
Button.js
import { connect, actions } from 'mirrorx'
const Button = ({value, handleClick}) => (
<button onClick={handleClick}>
{value}
# NPM Unfuck | |
# Brought to you by: | |
# Mackenzie Kieran & Shawn McKay | |
# remove deps | |
rm -rf node_modules | |
npm cache clean | |
# lock dependencies |
if which yarn > /dev/null; then | |
yarn | |
else | |
npm install | |
fi |