Skip to content

Commit 6a5b3b1

Browse files
committed
fix: Reload w/ ?code query param
1 parent 6dfd391 commit 6a5b3b1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/components/controllers/repl/index.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function Repl({ code }) {
4747

4848
// Clears the (now outdated) example & code query params
4949
// when a user begins to modify the code
50-
if (query.example || query.code) {
50+
if (location.search) {
5151
route('/repl', true);
5252
}
5353
};
@@ -56,7 +56,9 @@ export function Repl({ code }) {
5656
// No reason to share semi-sketchy btoa'd code if there's
5757
// a perfectly good example we can use instead
5858
if (!query.example) {
59-
route(`/repl?code=${encodeURIComponent(btoa(editorCode))}`, true);
59+
// We use `history.replaceState` here as the code is only relevant on mount.
60+
// There's no need to notify the router of the change.
61+
history.replaceState(null, null, `/repl?code=${encodeURIComponent(btoa(editorCode))}`);
6062
}
6163

6264
try {

0 commit comments

Comments
 (0)