Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

/.idea
package-lock.json
# dependencies
/node_modules
/.pnp
Expand Down
6,397 changes: 3,235 additions & 3,162 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
"react-redux": "^6.0.0",
"react-scripts": "2.1.1",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
33 changes: 16 additions & 17 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, {Component} from 'react';
import './App.css';
import {} from './redux/actions/actions';
import { connect } from "react-redux";

class App extends Component {

render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<h1>APP redux ready</h1>

</div>
);
}
}

export default App;

// THIS METHODS BELOW HAVE TO BE IN EVERY COMPONENT FILE IF ACCESS TO REDUX STORE NEEDED
const mapStateToProps = state => {
return {
};
};
const mapDispatchToProps = dispatch => ({

})
export default connect(mapStateToProps, mapDispatchToProps)(App);
13 changes: 11 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
import App from './App';
import store from './redux/store/store'


ReactDOM.render(
<Provider store={store}>
<App/>
</Provider>,
document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
1 change: 1 addition & 0 deletions src/redux/actionTypes/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ACTION_TYPE = 'ACTION_TYPE';
12 changes: 12 additions & 0 deletions src/redux/actions/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function increment () {

}

function decrement () {

}

export default {
increment,
decrement
}
11 changes: 11 additions & 0 deletions src/redux/reducers/rootReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { combineReducers } from 'redux';

// @REDUCERS
import testReducer from './testReducer';

// @ROOT REDUCER
const rootReducer = combineReducers({
testReducer
});

export default rootReducer;
26 changes: 26 additions & 0 deletions src/redux/reducers/testReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const initialState = {
testField: 'tratata',
lastAction: null,
value: 0
};

function testReducer(state = initialState, action) {
switch (action.type) {
case 'INCREMENT':
return {
...state,
lastAction: action.type,
value: ++initialState.value
};
case 'DECREMENT':
return {
...state,
lastAction: action.type,
value: --initialState.value
};
default:
return state;
}
}

export default testReducer;
14 changes: 14 additions & 0 deletions src/redux/store/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {createStore, applyMiddleware, compose} from 'redux';
import rootReducer from '../reducers/rootReducer';
import thunk from 'redux-thunk';
import logger from 'redux-logger';

const store = createStore(
rootReducer,
compose(
applyMiddleware(logger, thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
);

export default store;