From 230290d9be044c33f08dc947eedccd42d0ac19c8 Mon Sep 17 00:00:00 2001 From: lmhcoding <13265878974@163.com> Date: Thu, 1 Oct 2020 09:26:36 +0800 Subject: [PATCH] fix(useHistory): patch when is client --- src/useHistory.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/useHistory.ts b/src/useHistory.ts index 1f83335..b257bc1 100644 --- a/src/useHistory.ts +++ b/src/useHistory.ts @@ -22,8 +22,10 @@ function patchHistoryMethod(method: PathMethod): void { ) } -patchHistoryMethod('pushState') -patchHistoryMethod('replaceState') +if (typeof window !== 'undefined') { + patchHistoryMethod('pushState') + patchHistoryMethod('replaceState') +} export interface IHistoryState { state: any