add initial redux scafold

This commit is contained in:
Barry Gitarts 2018-06-01 10:25:59 -04:00
parent 728718199e
commit 389bc28a83
8 changed files with 61 additions and 3 deletions

View File

@ -44,4 +44,4 @@ class App extends React.Component {
}
}
ReactDOM.render(<App></App>, document.getElementById('app'));
export default App;

View File

@ -7,6 +7,6 @@
<body class="container">
<div id="app">
</div>
<script src="js/dapp.js"></script>
<script src="js/index.js" type="text/javascript"></script>
</body>
</html>

15
app/index.js Normal file
View File

@ -0,0 +1,15 @@
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import configureStore from './store/configureStore';
import App from './dapp';
import './dapp.css';
const store = configureStore();
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('app')
);

19
app/reducers/accounts.js Normal file
View File

@ -0,0 +1,19 @@
import { createTypes, actionCreator } from 'redux-action-creator'
export const types = createTypes([
'RECEIVE_ACCOUNTS'
], 'ACCOUNTS')
export const actions = {
receiveAccounts: actionCreator(types.RECEIVE_ACCOUNTS, 'accounts')
}
export default function accounts(state = [], action) {
switch (action.type) {
case types.RECEIVE_ACCOUNTS:
return { ...state, ...action.accounts }
default:
return state;
}
}
export const getAccounts = state => state.accounts;

View File

@ -0,0 +1,8 @@
import { combineReducers } from 'redux';
import accounts from './accounts'
const rootReducer = combineReducers({
accounts
});
export default rootReducer;

View File

@ -0,0 +1,11 @@
import { createStore, applyMiddleware } from 'redux';
import rootReducer from '../reducers/rootReducer';
import thunk from 'redux-thunk';
export default function configureStore() {
return createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
applyMiddleware(thunk)
);
}

View File

@ -2,6 +2,7 @@
"contracts": ["contracts/**"],
"app": {
"js/dapp.js": ["app/dapp.js"],
"js/index.js": ["app/index.js"],
"index.html": "app/index.html",
"images/": ["app/images/**"]
},

View File

@ -21,7 +21,11 @@
"react": "^16.3.2",
"react-blockies": "^1.3.0",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.3.2"
"react-dom": "^16.3.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-action-creator": "^2.3.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-plugin-transform-object-rest-spread": "^6.26.0",