本文整理汇总了TypeScript中history/createMemoryHistory.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createMemoryHistory
export default function createHistory<T>(
initialEntries: HistoryEntry | Readonly<HistoryEntry[]> = '/',
matchParams: MatchShape = {},
): RouteComponentProps<T> {
const entries = _.castArray(initialEntries);
const history = createMemoryHistory({ initialEntries: entries as any });
const { params = {}, isExact = true } = matchParams;
const match = {
params,
isExact,
path: entries[0],
url: entries[0],
} as any;
return {
history,
match,
location: history.location,
};
}
示例2: it
it('should replace the current history item if push is false', () => {
const history = createMemoryHistory();
const { syncToBrowser } = mkBrowser([], history);
syncToBrowser({ view: 'foo', foo: 'bar' }, false);
expect(history.location.pathname).toBe('/foo');
expect(history.location.search).toBe('?foo=bar');
expect(history.length).toBe(1);
});