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 committed Sep 3, 2022
1 parent 3d9a72f commit 47db8a3
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 />", () => {
`1234 + "/socket"`
);
});

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 @@ -1474,9 +1474,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 @@ -1519,7 +1521,7 @@ export const LiveReload =
remixLiveReloadConnect({
onOpen: () => window.location.reload(),
}),
1000
${String(timeout)}
);
};
ws.onerror = (error) => {
Expand Down

0 comments on commit 47db8a3

Please sign in to comment.