-
Notifications
You must be signed in to change notification settings - Fork 642
Conversation
|
||
const method = routing.replace ? 'replace' : 'push'; | ||
const locationParam = (!!routing.state && typeof routing.path === 'String') ? | ||
routing.path : { state: routing.state, pathname: routing.path} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for switching between string and object based on state
? Much easier to read the code if we can always send an object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we can just send the object, it works both ways will rebase
I like the idea of renaming |
@@ -92,7 +90,7 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) { | |||
|
|||
const unsubscribeHistory = history.listen(location => { | |||
const route = { | |||
path: history.createPath(location), | |||
path: history.createHref(location), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed to extract the url encoded path for current implementation. if we decided to mirror history
location objects with query params, this line will not be necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the line that is breaking the tests in the browser. Changing back to createPath
makes the tests pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried createPath
but devtools tests were still failing... did you update deps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, missed something... See new comment.
Do we want to be using beta releases in the examples? We should bear in mind that people are going to be treating this code as best practice. I will add that I've been using the Devtools beta release and think that it is solid. Maybe the decision to use a beta should be on a case by case basis. This PR also bumps webpack to the 2.0 beta release, can we justify this? It gives off some peer dependency warnings on |
@ellbee I agree — I thought about raising the same issue. I'm generally not a big fan of relying on beta releases in code people will copy when learning something new. I would prefer this PR without the beta releases, especially the Webpack upgrade. |
@ellbee i agree that |
@@ -160,14 +159,15 @@ module.exports = function createTests(createHistory, name, reset = defaultReset) | |||
|
|||
beforeEach(() => { | |||
history = createHistory(); | |||
const finalCreateStore = compose(devTools())(createStore); | |||
|
|||
const finalCreateStore = compose(instrument())(createStore); | |||
store = finalCreateStore(combineReducers({ | |||
routing: routeReducer | |||
})); | |||
devToolsStore = store.devToolsStore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be store.liftedStore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
👍 |
@jlongster @ellbee if we're syncing type LocationDescriptorObject = {
pathname: Pathname;
search: Search;
query: Query;
state: LocationState;
};
type LocationDescriptor = LocationDescriptorObject | Path; it's super minimal, and there's really nothing in there that would pollute the redux store. query support could be optional but supported since import { createHistory, useQueries } from 'history'
const history = useQueries(createHistory)()
history.createPath({ pathname: '/the/path', query: { the: 'query' } })
history.push({ pathname: '/the/path', query: { the: 'query' } }) please let me know what you guys think |
It definitely seems easier to support query params with the new release of It ends up being a huge change. I would rather see a clean PR with |
I agree with @kjbekkelund on both points. |
ok cool i moved README updates to #93, removed webpack beta and reverted |
@@ -2,4 +2,4 @@ const { createHashHistory, createHistory } = require('history'); | |||
const createTests = require('../createTests.js'); | |||
|
|||
createTests(createHashHistory, 'Hash History', () => window.location = '#/'); | |||
createTests(createHistory, 'Browser History', () => window.history.replaceState(null, null, '/')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this is needed?
Nice, I'll test it out later today :) |
New Devtools and Webpack releases are imminent. I’m not sure why devtools tests are failing on this commit I will look into more tomorrow. If you run the example, everything works beautifully.
I don't have time to go through all of this right now, but I'm a little worried because right now we don't tie ourselves to any version of Which kind of sucks. It gets tricky to make sure the user is using the right version of history with the right version of this lib. We need to look into how to make that work. |
@jlongster no worries! this pr just brings things up to date with
since rackt is implementing more formal versioning it probably makes sense for in terms of adding new features, ie. support for query and search, @kjbekkelund started a conversation and outlined some implementation options in #95 |
@justingreenberg As we need to think more about how to handle the |
@kjbekkelund now that devtools is stable i'll submit new PR in the morning for devtools update @jlongster what are you thinking in terms of other updates to sync up with new history api? since there are merge conflicts and i'm splitting out devtools anyway, would you like me to to close this PR, clean them up and submit new pr? please let me know :) |
@justingreenberg Awesome 💯 |
@justingreenberg You can create a new clean PR with just updating the history integration. Just make sure to link this one so it's easy to follow the discussion. I have more time now so when you open a new PR I'll take a closer look at it. |
Also I agree that we should update to whatever the newest |
Resolves #69 #92
The example is updated and routing/devtools are working as expected—routing remains synced with store and devtools, instrumentation toggles sync with routing (reset, revert, sweep), etc
A couple of things to consider:
react-router
(ie,pathname
instead ofpath
)LocationDescriptorObject
? i know it's a common feature request and would be trivial to implementBased on the new API, I'm thinking we should just mirror the whole
history.LocationDescriptorObject
—it's very simple and contains all relevant state inwindow.location
...@jlongster @kjbekkelund ellbee what do you guys think?