diff --git a/src/withESI.test.tsx b/src/withESI.test.tsx
index 875fcbc..385da72 100644
--- a/src/withESI.test.tsx
+++ b/src/withESI.test.tsx
@@ -1,4 +1,3 @@
-import express from "express";
import React from "react";
import renderer from "react-test-renderer";
import withESI from "./withESI";
@@ -9,7 +8,7 @@ test("client-side", () => {
const DummyESI = withESI(Dummy, "id");
expect(DummyESI.displayName).toBe("WithESI(Dummy)");
- (global.process as any).browser = true;
+ (global as any).navigator = {};
const component = renderer.create();
expect(component).toMatchSnapshot();
});
@@ -18,7 +17,7 @@ test("client-side with serialized props", () => {
const DummyESI = withESI(Dummy, "id");
expect(DummyESI.displayName).toBe("WithESI(Dummy)");
- (global.process as any).browser = true;
+ (global as any).navigator = {};
((global as any).__REACT_ESI__ as any) = { id: { name: "Anne" } };
const component = renderer.create();
expect(component).toMatchSnapshot();
@@ -35,7 +34,7 @@ test("client-side call getInitialProps", async () => {
const ComponentESI = withESI(Component, "initial-props");
- (global.process as any).browser = true;
+ (global as any).navigator = {};
renderer.create();
expect(called).toBe(true);
});
@@ -45,7 +44,7 @@ test("server-side", () => {
expect(DummyESI.displayName).toBe("WithESI(Dummy)");
process.env.REACT_ESI_SECRET = "dummy";
- (global.process as any).browser = false;
+ delete (global as any).navigator;
const component = renderer.create(
);
diff --git a/src/withESI.tsx b/src/withESI.tsx
index 22bdae8..7995bfb 100644
--- a/src/withESI.tsx
+++ b/src/withESI.tsx
@@ -8,10 +8,6 @@ declare global {
}
}
-interface IWebpackProcess extends NodeJS.Process {
- browser?: boolean;
-}
-
interface IWithESIProps {
esi?: {
attrs?: object;
@@ -46,7 +42,7 @@ export default function withESI
(
this.esi = esi || {};
this.state.childProps = childProps;
- if (!(process as IWebpackProcess).browser) {
+ if (typeof navigator === 'undefined') {
return;
}
@@ -81,7 +77,7 @@ export default function withESI
(
}
public render() {
- if ((process as IWebpackProcess).browser) {
+ if (typeof navigator !== 'undefined') {
return (