rename createBrowserHistory to createHistory

`createBrowserHistory ` was only introduced in the `history@4.0.0-1`
prior to that the `createHistory` was used. So if you will install
`@types/history@^2.0.0` and `history@^2.0.0`(or even `^3.x.x`) it will
break with the next error:
```
./src/client/history.ts
(1,10): error TS2305: Module ‘”/@types/history/index"' has no exported
member 'createHistory'.
```
This commit brings the `createHistory` back thus solves the issue for
`history@^2.x.x` and `history@^3.x.x`.
This commit is contained in:
Oleg Solomka 2017-01-23 16:14:41 -06:00
parent d7ee5b897b
commit ef8a64d27c
2 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
import { getUserConfirmation } from 'history/lib/DOMUtils'
@ -10,7 +10,7 @@ let doSomethingAsync: () => Promise<Function>;
let input = { value: "" };
{
let history = createBrowserHistory()
let history = createHistory()
// Listen for changes to the current location. The
// listener is called once immediately.
@ -46,7 +46,7 @@ let input = { value: "" };
}
{
let history = createBrowserHistory()
let history = createHistory()
// Pushing a path string.
history.push('/the/path')
@ -63,7 +63,7 @@ let input = { value: "" };
}
{
let history = createBrowserHistory()
let history = createHistory()
history.listenBefore(function(location) {
if (input.value !== '')
return 'Are you sure you want to leave this page?'
@ -75,7 +75,7 @@ let input = { value: "" };
}
{
let history = createBrowserHistory({
let history = createHistory({
getUserConfirmation(message, callback) {
callback(window.confirm(message)) // The default behavior
}
@ -83,7 +83,7 @@ let input = { value: "" };
}
{
let history = useBeforeUnload(createBrowserHistory)()
let history = useBeforeUnload(createHistory)()
history.listenBeforeUnload(function() {
return 'Are you sure you want to leave this page?'
@ -91,7 +91,7 @@ let input = { value: "" };
}
{
let history = useQueries(createBrowserHistory)()
let history = useQueries(createHistory)()
history.listen(function(location) {
console.log(location.query)
@ -99,7 +99,7 @@ let input = { value: "" };
}
{
let history = useQueries(createBrowserHistory)({
let history = useQueries(createHistory)({
parseQueryString: function(queryString) {
// TODO: return a parsed version of queryString
return {};
@ -116,7 +116,7 @@ let input = { value: "" };
{
// Run our app under the /base URL.
let history = useBasename(createBrowserHistory)({
let history = useBasename(createHistory)({
basename: '/base'
})
@ -128,4 +128,4 @@ let input = { value: "" };
history.createPath('/the/path') // /base/the/path
history.push('/the/path') // push /base/the/path
}
}

View File

@ -127,7 +127,7 @@ export interface Module {
};
}
export { default as createBrowserHistory } from "./lib/createBrowserHistory";
export { default as createHistory } from "./lib/createBrowserHistory";
export { default as createHashHistory } from "./lib/createHashHistory";
export { default as createMemoryHistory } from "./lib/createMemoryHistory";
export { default as createLocation } from "./lib/createLocation";