Skip to content

Commit

Permalink
Merge pull request reactjs#70 from geowarin/dev-tools
Browse files Browse the repository at this point in the history
Add Dev tools
  • Loading branch information
jlongster committed Dec 4, 2015
2 parents 8422f9f + fafe07a commit fe7487a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
28 changes: 19 additions & 9 deletions examples/basic/app.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
const React = require('react');
const ReactDOM = require('react-dom');
const { createStore, combineReducers } = require('redux');
const { compose, createStore, combineReducers } = require('redux');
const { Provider } = require('react-redux');
const { Router, Route, IndexRoute } = require('react-router');
const createHistory = require('history/lib/createHashHistory');
const { syncReduxAndRouter, routeReducer } = require('redux-simple-router');
import { devTools } from 'redux-devtools';
const { DevTools, DebugPanel, LogMonitor } = require('redux-devtools/lib/react');

const reducers = require('./reducers');
const { App, Home, Foo, Bar } = require('./components');

const reducer = combineReducers(Object.assign({}, reducers, {
routing: routeReducer
}));
const store = createStore(reducer);
const finalCreateStore = compose(
devTools()
)(createStore);
const store = finalCreateStore(reducer);
const history = createHistory();

syncReduxAndRouter(history, store);

ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Home}/>
<Route path="foo" component={Foo}/>
<Route path="bar" component={Bar}/>
</Route>
</Router>
<div>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Home}/>
<Route path="foo" component={Foo}/>
<Route path="bar" component={Bar}/>
</Route>
</Router>
<DebugPanel top right bottom>
<DevTools store={store} monitor={LogMonitor} />
</DebugPanel>
</div>
</Provider>,
document.getElementById('mount')
);
8 changes: 4 additions & 4 deletions examples/basic/components/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const React = require('react');
const { Link } = require('react-router');
const { connect } = require('react-redux');
const { updatePath } = require('redux-simple-router');
const { pushPath } = require('redux-simple-router');

function App({ updatePath, children }) {
function App({ pushPath, children }) {
return (
<div>
<header>
Expand All @@ -16,7 +16,7 @@ function App({ updatePath, children }) {
<Link to="/bar">Bar</Link>
</header>
<div>
<button onClick={() => updatePath('/foo')}>Go to /foo</button>
<button onClick={() => pushPath('/foo')}>Go to /foo</button>
</div>
<div style={{marginTop: '1.5em'}}>{children}</div>
</div>
Expand All @@ -25,5 +25,5 @@ function App({ updatePath, children }) {

module.exports = connect(
null,
{ updatePath }
{ pushPath }
)(App);
4 changes: 4 additions & 0 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"redux-devtools": "^2.1.5",
"webpack": "^1.12.6"
},
"scripts": {
"start": "webpack --watch"
}
}

0 comments on commit fe7487a

Please sign in to comment.