Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

Commit a452791

Browse files
committed
Merge pull request #265 from webmasterkai/actionTypeAlt
rename UPDATE_LOCATION to CALL_HISTORY_METHOD
2 parents 2b177f5 + 2c88667 commit a452791

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ function MyComponent({ dispatch }) {
8383
}
8484
```
8585

86-
This will change the state, which will trigger a change in react-router. Additionally, if you want to respond to the path update action, just handle the `UPDATE_LOCATION` constant that we provide:
86+
This will change the state, which will trigger a change in react-router. Additionally, if you want to respond to the path update action, just handle the `CALL_HISTORY_METHOD` constant that we provide:
8787

8888
```js
89-
import { UPDATE_LOCATION } from 'react-router-redux'
89+
import { CALL_HISTORY_METHOD } from 'react-router-redux'
9090

9191
function update(state, action) {
9292
switch(action.type) {
93-
case UPDATE_LOCATION:
93+
case CALL_HISTORY_METHOD:
9494
// do something here
9595
}
9696
}
@@ -142,7 +142,7 @@ A reducer function that keeps track of the router state. You must add this reduc
142142

143143
**Warning:** It is a bad pattern to use `react-redux`'s `connect` decorator to map the state from this reducer to props on your `Route` components. This can lead to infinite loops and performance problems. `react-router` already provides this for you via `this.props.location`.
144144

145-
#### `UPDATE_LOCATION`
145+
#### `CALL_HISTORY_METHOD`
146146

147147
An action type that you can listen for in your reducers to be notified of route updates.
148148

src/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* If you're writing a middleware to watch for navigation events, be sure to
44
* look for actions of this type.
55
*/
6-
export const UPDATE_LOCATION = '@@router/UPDATE_LOCATION'
6+
export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD'
77

88
function updateLocation(method) {
99
return (...args) => ({
10-
type: UPDATE_LOCATION,
10+
type: CALL_HISTORY_METHOD,
1111
payload: { method, args }
1212
})
1313
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export syncHistoryWithStore from './sync'
22
export { LOCATION_CHANGE, routerReducer } from './reducer'
33

44
export {
5-
UPDATE_LOCATION,
5+
CALL_HISTORY_METHOD,
66
push, replace, go, goBack, goForward,
77
routeActions
88
} from './actions'

src/middleware.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { UPDATE_LOCATION } from './actions'
1+
import { CALL_HISTORY_METHOD } from './actions'
22

33
/**
4-
* This middleware captures UPDATE_LOCATION actions to redirect to the
4+
* This middleware captures CALL_HISTORY_METHOD actions to redirect to the
55
* provided history object. This will prevent these actions from reaching your
66
* reducer or any middleware that comes after this one.
77
*/
88
export default function routerMiddleware(history) {
99
return () => next => action => {
10-
if (action.type !== UPDATE_LOCATION) {
10+
if (action.type !== CALL_HISTORY_METHOD) {
1111
return next(action)
1212
}
1313

test/actions.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import expect from 'expect'
22

33
import {
4-
UPDATE_LOCATION,
4+
CALL_HISTORY_METHOD,
55
push, replace, go, goBack, goForward
66
} from '../src/actions'
77

@@ -10,15 +10,15 @@ describe('routeActions', () => {
1010
describe('push', () => {
1111
it('creates actions', () => {
1212
expect(push('/foo')).toEqual({
13-
type: UPDATE_LOCATION,
13+
type: CALL_HISTORY_METHOD,
1414
payload: {
1515
method: 'push',
1616
args: [ '/foo' ]
1717
}
1818
})
1919

2020
expect(push({ pathname: '/foo', state: { the: 'state' } })).toEqual({
21-
type: UPDATE_LOCATION,
21+
type: CALL_HISTORY_METHOD,
2222
payload: {
2323
method: 'push',
2424
args: [ {
@@ -29,7 +29,7 @@ describe('routeActions', () => {
2929
})
3030

3131
expect(push('/foo', 'baz', 123)).toEqual({
32-
type: UPDATE_LOCATION,
32+
type: CALL_HISTORY_METHOD,
3333
payload: {
3434
method: 'push',
3535
args: [ '/foo' , 'baz', 123 ]
@@ -41,15 +41,15 @@ describe('routeActions', () => {
4141
describe('replace', () => {
4242
it('creates actions', () => {
4343
expect(replace('/foo')).toEqual({
44-
type: UPDATE_LOCATION,
44+
type: CALL_HISTORY_METHOD,
4545
payload: {
4646
method: 'replace',
4747
args: [ '/foo' ]
4848
}
4949
})
5050

5151
expect(replace({ pathname: '/foo', state: { the: 'state' } })).toEqual({
52-
type: UPDATE_LOCATION,
52+
type: CALL_HISTORY_METHOD,
5353
payload: {
5454
method: 'replace',
5555
args: [ {
@@ -64,7 +64,7 @@ describe('routeActions', () => {
6464
describe('go', () => {
6565
it('creates actions', () => {
6666
expect(go(1)).toEqual({
67-
type: UPDATE_LOCATION,
67+
type: CALL_HISTORY_METHOD,
6868
payload: {
6969
method: 'go',
7070
args: [ 1 ]
@@ -76,7 +76,7 @@ describe('routeActions', () => {
7676
describe('goBack', () => {
7777
it('creates actions', () => {
7878
expect(goBack()).toEqual({
79-
type: UPDATE_LOCATION,
79+
type: CALL_HISTORY_METHOD,
8080
payload: {
8181
method: 'goBack',
8282
args: []
@@ -88,7 +88,7 @@ describe('routeActions', () => {
8888
describe('goForward', () => {
8989
it('creates actions', () => {
9090
expect(goForward()).toEqual({
91-
type: UPDATE_LOCATION,
91+
type: CALL_HISTORY_METHOD,
9292
payload: {
9393
method: 'goForward',
9494
args: []

0 commit comments

Comments
 (0)