Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Update history module lib def #251

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions flow-typed/npm/history_v4.x.x.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// @flow
// flow-typed signature: 540e42745f797051f3bf17a6af1ccf06
// flow-typed version: 6a3fe49a8b/history_v4.x.x/flow_>=v0.25.x

declare module 'history' {
declare type LocationType = {
pathname: string,
Expand All @@ -16,9 +13,7 @@ declare module 'history' {
declare function createPath(
path: string | LocationType
): string | LocationType;
}

declare module 'history/createBrowserHistory' {
declare function Unblock(): void;

declare export type Action = 'PUSH' | 'REPLACE' | 'POP';
Expand All @@ -28,8 +23,8 @@ declare module 'history/createBrowserHistory' {
search: string,
hash: string,
// Browser and Memory specific
state?: {},
key?: string,
state: {},
key: string,
};

declare interface IBrowserHistory {
Expand All @@ -39,19 +34,20 @@ declare module 'history/createBrowserHistory' {
push(path: string, state?: {}): void;
push(location: $Shape<BrowserLocation>): void;
replace(path: string, state?: {}): void;
replace(path: $Shape<BrowserLocation>, state?: {}): void;
replace(location: $Shape<BrowserLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
listen: any;
listen: Function;
block(message: string): typeof Unblock;
block(
callback: (location: BrowserLocation, action: Action) => boolean
): void;
(location: BrowserLocation, action: Action) => string
): typeof Unblock;
}

declare export type BrowserHistory = IBrowserHistory;

declare type HistoryOpts = {
declare type BrowserHistoryOpts = {
basename?: string,
forceRefresh?: boolean,
getUserConfirmation?: (
Expand All @@ -60,13 +56,9 @@ declare module 'history/createBrowserHistory' {
) => void,
};

declare export default (opts?: HistoryOpts) => BrowserHistory;
}

declare module 'history/createMemoryHistory' {
declare function Unblock(): void;

declare export type Action = 'PUSH' | 'REPLACE' | 'POP';
declare function createBrowserHistory(
opts?: BrowserHistoryOpts
): BrowserHistory;

declare export type MemoryLocation = {
pathname: string,
Expand Down Expand Up @@ -99,7 +91,7 @@ declare module 'history/createMemoryHistory' {

declare export type MemoryHistory = IMemoryHistory;

declare type HistoryOpts = {
declare type MemoryHistoryOpts = {
initialEntries?: Array<string>,
initialIndex?: number,
keyLength?: number,
Expand All @@ -109,13 +101,7 @@ declare module 'history/createMemoryHistory' {
) => void,
};

declare export default (opts?: HistoryOpts) => MemoryHistory;
}

declare module 'history/createHashHistory' {
declare function Unblock(): void;

declare export type Action = 'PUSH' | 'REPLACE' | 'POP';
declare function createMemoryHistory(opts?: MemoryHistoryOpts): MemoryHistory;

declare export type HashLocation = {
pathname: string,
Expand All @@ -142,7 +128,7 @@ declare module 'history/createHashHistory' {

declare export type HashHistory = IHashHistory;

declare type HistoryOpts = {
declare type HashHistoryOpts = {
basename?: string,
hashType: 'slash' | 'noslash' | 'hashbang',
getUserConfirmation?: (
Expand All @@ -151,5 +137,5 @@ declare module 'history/createHashHistory' {
) => void,
};

declare export default (opts?: HistoryOpts) => HashHistory;
declare function createHashHistory(opts?: HashHistoryOpts): HashHistory;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"./dist/browser.es2015.es.js": "./dist/browser.es2017.es.js"
},
"dependencies": {
"history": "^4.7.2",
"history": "^4.9.0",
"prop-types": "^15.6.2",
"react-router-dom": "^4.3.1"
},
Expand Down
4 changes: 3 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import * as React from 'react';
import {Router as DefaultProvider} from 'react-router-dom';
import createBrowserHistory from 'history/createBrowserHistory';
import {createBrowserHistory} from 'history';

import {UniversalEventsToken} from 'fusion-plugin-universal-events';
import {createPlugin, createToken, html, unescape, memoize} from 'fusion-core';
Expand Down Expand Up @@ -147,9 +147,11 @@ const plugin: FusionPlugin<PluginDepsType, HistoryWrapperType> = createPlugin({
if (!browserHistory) {
browserHistory = createBrowserHistory({basename: ctx.prefix});
}
// $FlowFixMe
myAPI.history = browserHistory;
ctx.element = (
<Router
// $FlowFixMe
history={browserHistory}
Provider={Provider}
basename={ctx.prefix}
Expand Down
Loading