diff options
| author | Haishan <[email protected]> | 2018-10-23 22:43:12 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2018-10-23 22:43:12 +0800 |
| commit | 09c6bf12e93ba265898c46f00bc73891cb2896dd (patch) | |
| tree | 44ebd4dbd4d67cc97f70235c68747b6f3066d98a /src | |
| parent | 580a61687ba137734d80589319f127539657a443 (diff) | |
deps: get rid of the deprecated react-router-redux
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Root.js | 7 | ||||
| -rw-r--r-- | src/components/SideBar.js | 28 | ||||
| -rw-r--r-- | src/ducks/index.js | 2 | ||||
| -rw-r--r-- | src/store/configureStore.js | 11 |
4 files changed, 13 insertions, 35 deletions
diff --git a/src/components/Root.js b/src/components/Root.js index 90144ff..7c6622a 100644 --- a/src/components/Root.js +++ b/src/components/Root.js @@ -1,8 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; -import { ConnectedRouter } from 'react-router-redux'; -import { Route } from 'react-router-dom'; +import { Router, Route } from 'react-router-dom'; import { hot } from 'react-hot-loader'; import SideBar from 'c/SideBar'; @@ -33,7 +32,7 @@ import s0 from './Root.module.scss'; const Root = ({ store, history }) => ( <Provider store={store}> - <ConnectedRouter history={history}> + <Router history={history}> <div className={s0.app}> <APIDiscovery /> <Route path="/" component={SideBar} /> @@ -45,7 +44,7 @@ const Root = ({ store, history }) => ( <Route exact path="/proxies" component={Proxies} /> </div> </div> - </ConnectedRouter> + </Router> </Provider> ); // <Route exact path="/__0" component={StyleGuide} /> diff --git a/src/components/SideBar.js b/src/components/SideBar.js index 5e2d8e6..e12f276 100644 --- a/src/components/SideBar.js +++ b/src/components/SideBar.js @@ -1,9 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { Link } from 'react-router-dom'; - -import { connect } from 'react-redux'; -// import { bindActionCreators } from 'redux'; +import { NavLink } from 'react-router-dom'; import Icon from 'c/Icon'; @@ -15,37 +12,24 @@ import yacd from 's/yacd.svg'; import s from 'c/SideBar.module.scss'; -class SideBarRowDump extends Component { +class SideBarRow extends Component { static propTypes = { to: PropTypes.string.isRequired, iconId: PropTypes.string, - labelText: PropTypes.string, - pathname: PropTypes.string + labelText: PropTypes.string }; render() { - const { iconId, labelText, to, pathname } = this.props; - const cls = pathname === to ? s.rowActive : s.row; + const { iconId, labelText, to } = this.props; return ( - <Link to={to} className={cls}> + <NavLink exact to={to} className={s.row} activeClassName={s.rowActive}> <Icon id={iconId} width={28} height={28} /> <div className={s.label}>{labelText}</div> - </Link> + </NavLink> ); } } -const mapStateToProps = state => { - const { pathname } = state.router.location; - return { pathname }; -}; -const mapDispatchToProps = null; - -const SideBarRow = connect( - mapStateToProps, - mapDispatchToProps -)(SideBarRowDump); - class SideBar extends Component { render() { return ( diff --git a/src/ducks/index.js b/src/ducks/index.js index 96f6d25..3b4d4c4 100644 --- a/src/ducks/index.js +++ b/src/ducks/index.js @@ -1,12 +1,10 @@ import { combineReducers } from 'redux'; -import { routerReducer as router } from 'react-router-redux'; import app from './app'; import modals from './modals'; import proxies from './proxies'; import configs from './configs'; export default combineReducers({ - router, app, modals, proxies, diff --git a/src/store/configureStore.js b/src/store/configureStore.js index 0be0cd8..0c8c201 100644 --- a/src/store/configureStore.js +++ b/src/store/configureStore.js @@ -2,18 +2,15 @@ import { createStore, applyMiddleware, compose } from 'redux'; import thunkMiddleware from 'redux-thunk'; import createHistory from 'history/createHashHistory'; // import createHistory from 'history/createBrowserHistory'; -import { routerMiddleware } from 'react-router-redux'; import rootReducer from '../ducks'; // const preloadedState = loadState(); const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; -function configureStore(history) { +function configureStore() { const store = createStore( rootReducer, - composeEnhancers( - applyMiddleware(thunkMiddleware, routerMiddleware(history)) - ) + composeEnhancers(applyMiddleware(thunkMiddleware)) ); if (module.hot) { @@ -28,6 +25,6 @@ function configureStore(history) { } const history = createHistory(); -const store = configureStore(history); +const store = configureStore(); -export { store, history } +export { store, history }; |
