Skip to content

Commit

Permalink
configure timeout for livereload component
Browse files Browse the repository at this point in the history
  • Loading branch information
joelazar authored and pcattori committed Jan 23, 2023
1 parent f8000db commit 90b64b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/remix-react/__tests__/components-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ describe("<LiveReload />", () => {
"let port = (window.__remixContext.dev && window.__remixContext.dev.liveReloadPort) || 1234;"
);
});

it("timeout of reload is set to 200ms", () => {
LiveReload = require("../components").LiveReload;
let { container } = render(<LiveReload timeout={200} />);
expect(container.querySelector("script")).toHaveTextContent(
"setTimeout( () => remixLiveReloadConnect({ onOpen: () => window.location.reload(), }), 200 );"
);
});
});
});

Expand Down
4 changes: 3 additions & 1 deletion packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1536,9 +1536,11 @@ export const LiveReload =
? () => null
: function LiveReload({
port = Number(process.env.REMIX_DEV_SERVER_WS_PORT || 8002),
timeout = 1000,
nonce = undefined,
}: {
port?: number;
timeout?: number;
/**
* @deprecated this property is no longer relevant.
*/
Expand Down Expand Up @@ -1582,7 +1584,7 @@ export const LiveReload =
remixLiveReloadConnect({
onOpen: () => window.location.reload(),
}),
1000
${String(timeout)}
);
}
};
Expand Down

0 comments on commit 90b64b0

Please sign in to comment.