From e150b35e33dac9a97aee56da7abcfd1421fa3388 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 3 Jun 2018 20:12:40 +0200 Subject: [PATCH] Wired redux --- package.json | 1 + src/App.js | 9 ++++++--- src/common/MainHeader.js | 2 +- src/common/MenuLayout.js | 13 +++++++++++++ src/index.js | 18 +++++++++++++----- src/reducers/index.js | 5 +++++ src/servers/ServersDropdown.js | 5 ++++- 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 src/common/MenuLayout.js create mode 100644 src/reducers/index.js diff --git a/package.json b/package.json index 029b3241..ee7c319e 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "react-redux": "^5.0.7", "react-router-dom": "^4.2.2", "reactstrap": "^6.0.1", + "redux": "^4.0.0", "resolve": "1.6.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", diff --git a/src/App.js b/src/App.js index 14a7a6f7..3e5a7cd3 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,9 @@ import React from 'react'; -import './App.scss'; import { Route, Switch } from 'react-router-dom'; +import './App.scss'; import Home from './common/Home'; import MainHeader from './common/MainHeader'; +import MenuLayout from './common/MenuLayout'; import CreateServer from './servers/CreateServer'; export default class App extends React.Component { @@ -10,10 +11,12 @@ export default class App extends React.Component { return (
+
- - + + +
diff --git a/src/common/MainHeader.js b/src/common/MainHeader.js index 5bf75560..d8e8287b 100644 --- a/src/common/MainHeader.js +++ b/src/common/MainHeader.js @@ -12,7 +12,7 @@ export default class MainHeader extends React.Component { super(props); this.state = { - isOpen: false + isOpen: false, }; } diff --git a/src/common/MenuLayout.js b/src/common/MenuLayout.js new file mode 100644 index 00000000..e2e56f10 --- /dev/null +++ b/src/common/MenuLayout.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { Switch } from 'react-router-dom'; + +export default () => { + return ( +
+ + + + +
+ ); +} diff --git a/src/index.js b/src/index.js index 5b3baa1e..092c2ff1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,23 @@ +import 'bootstrap/dist/css/bootstrap.min.css'; import React from 'react'; import ReactDOM from 'react-dom'; -import 'bootstrap/dist/css/bootstrap.min.css'; -import './index.scss'; +import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; +import { applyMiddleware, createStore } from 'redux'; import App from './App'; +import './index.scss'; +import reducers from './reducers'; import registerServiceWorker from './registerServiceWorker'; +// const store = createStore(reducers, {}, applyMiddleware()); +const store = createStore(reducers, applyMiddleware()); + ReactDOM.render( - - - , + + + + + , document.getElementById('root') ); registerServiceWorker(); diff --git a/src/reducers/index.js b/src/reducers/index.js new file mode 100644 index 00000000..45d0591f --- /dev/null +++ b/src/reducers/index.js @@ -0,0 +1,5 @@ +import { combineReducers } from 'redux'; + +const rootReducer = combineReducers({}); + +export default rootReducer; diff --git a/src/servers/ServersDropdown.js b/src/servers/ServersDropdown.js index b7b1ea19..d9fba7f2 100644 --- a/src/servers/ServersDropdown.js +++ b/src/servers/ServersDropdown.js @@ -1,7 +1,8 @@ import React from 'react'; import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap'; +import { connect } from 'react-redux'; -export default class ServersDropdown extends React.Component { +class ServersDropdown extends React.Component { render() { return ( @@ -21,3 +22,5 @@ export default class ServersDropdown extends React.Component { ); } } + +export default connect()(ServersDropdown);