Skip to content

Commit 352f079

Browse files
committed
Example of using isMonitorAction
Related to #140.
1 parent dbc6c05 commit 352f079

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/counter/components/Counter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import React, { Component, PropTypes } from 'react';
2+
import { isMonitorAction } from '../store/configureStore';
23

34
class Counter extends Component {
45
render() {
56
const { increment, incrementIfOdd, incrementAsync, decrement, counter } = this.props;
67
return (
78
<p>
89
Clicked: {counter} times
10+
{
11+
process.env.NODE_ENV === 'production' || !isMonitorAction() ? '*' :
12+
<strong> (changed by monitor) </strong>
13+
}
914
{' '}
1015
<button onClick={increment}>+</button>
1116
{' '}

examples/counter/store/configureStore.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import thunk from 'redux-thunk';
33
import invariant from 'redux-immutable-state-invariant';
44
import reducer from '../reducers';
55

6+
export let isMonitorAction;
67
export default function configureStore(initialState) {
78
const store = createStore(reducer, initialState, compose(
89
applyMiddleware(invariant(), thunk),
9-
window.devToolsExtension ? window.devToolsExtension() : f => f
10+
window.devToolsExtension ? window.devToolsExtension({
11+
getMonitor: (monitor) => { isMonitorAction = monitor.isMonitorAction; }
12+
}) : f => f
1013
));
1114

1215
if (module.hot) {

0 commit comments

Comments
 (0)