Skip to content

Commit

Permalink
Example of using isMonitorAction
Browse files Browse the repository at this point in the history
Related to #140.
  • Loading branch information
zalmoxisus committed Jul 15, 2016
1 parent dbc6c05 commit 352f079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/counter/components/Counter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React, { Component, PropTypes } from 'react';
import { isMonitorAction } from '../store/configureStore';

class Counter extends Component {
render() {
const { increment, incrementIfOdd, incrementAsync, decrement, counter } = this.props;
return (
<p>
Clicked: {counter} times
{
process.env.NODE_ENV === 'production' || !isMonitorAction() ? '*' :
<strong> (changed by monitor) </strong>
}
{' '}
<button onClick={increment}>+</button>
{' '}
Expand Down
5 changes: 4 additions & 1 deletion examples/counter/store/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import thunk from 'redux-thunk';
import invariant from 'redux-immutable-state-invariant';
import reducer from '../reducers';

export let isMonitorAction;
export default function configureStore(initialState) {
const store = createStore(reducer, initialState, compose(
applyMiddleware(invariant(), thunk),
window.devToolsExtension ? window.devToolsExtension() : f => f
window.devToolsExtension ? window.devToolsExtension({
getMonitor: (monitor) => { isMonitorAction = monitor.isMonitorAction; }
}) : f => f
));

if (module.hot) {
Expand Down

0 comments on commit 352f079

Please sign in to comment.