dvdzkwsk / react-redux-starter-kit

Get started with React, Redux, and React-Router.
MIT License
10.29k stars 2.2k forks source link

updateLocation thunk strange behaviour #1137

Open gitteraz opened 7 years ago

gitteraz commented 7 years ago

hi, i am using the kit in my recent dashboard app. This is my first time using redux and your Starter kit made it very easy to catch up, Thank you!

One thing i am missing is why the LOCATION_CHANGE action creator doesn't always run the returning function when path changes,causing the location state to be always null.

export const updateLocation = ({ dispatch }) => {
 // this next block doesn't run (function stops here)
  return (nextLocation) => {
    dispatch(locationChange(nextLocation))
  }
}

Aditional info It happens even with a fresh installation of the starter kit when i include '#' to an url e.g 'localhost:3000#' it works and location state is updated successfully

Please point me in the right direction

macnibblet commented 7 years ago

I'm having the same problem, have you managed to solve it ?

gitteraz commented 7 years ago

@macnibblet i don't know if it's the right thing to do, will wait for proper fix but meanwhile i got it working by passing initial location state from window.location object.

in src/main.js

changed: const initialState = window.___INITIAL_STATE__

to: const initialState = { location : { hash: window.location.hash, pathname: window.location.pathname, search: window.location.search, key: null } }

And now the location state is updated.