Skip to content

Commit

Permalink
Merge pull request #69 from MrLoh/fix-attemptCallRouteThunk-location-bug
Browse files Browse the repository at this point in the history
fix: fix location access bug in attemptCallRouteThunk
  • Loading branch information
faceyspacey authored Aug 6, 2017
2 parents dea4829 + 735db24 commit b9ebe43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/connectRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ export default (
nextState = selectLocationState(state)

if (typeof route === 'object') {
attemptCallRouteThunk(dispatch, store.getState, route)
attemptCallRouteThunk(
dispatch,
store.getState,
route,
selectLocationState
)
}

if (onAfterChange) {
Expand Down
12 changes: 9 additions & 3 deletions src/pure-utils/attemptCallRouteThunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import type {
Dispatch,
GetState,
RouteObject,
LocationState
LocationState,
SelectLocationState
} from '../flow-types'

export default (dispatch: Dispatch, getState: GetState, route: RouteObject) => {
export default (
dispatch: Dispatch,
getState: GetState,
route: RouteObject,
selectLocationState: SelectLocationState
) => {
if (typeof window !== 'undefined') {
const thunk = route.thunk

if (typeof thunk === 'function') {
const { kind, hasSSR }: LocationState = getState().location
const { kind, hasSSR }: LocationState = selectLocationState(getState())

// call thunks always if it's not initial load of the app or only if it's load
// without SSR setup yet, so app state is setup on client when prototyping,
Expand Down

0 comments on commit b9ebe43

Please sign in to comment.