File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,23 @@ function EditorContainer(props) {
57
57
58
58
const snippetId = snippet && snippet . id
59
59
React . useEffect ( ( ) => {
60
- if ( '/' + ( snippetId || '' ) === props . router . asPath ) {
60
+ const snippetPath = '/' + ( snippetId || '' )
61
+ if ( snippetPath === props . router . asPath ) {
61
62
return
62
63
}
63
- window . history . pushState ( null , null , '/' + ( snippetId || '' ) )
64
- // props.router.replace(props.router.asPath, '/' + (snippetId || ''), { shallow: true })
64
+
65
+ // Reloads only if the snipped.id is different from before. Otherwise returns from above.
66
+ props . router . push (
67
+ {
68
+ pathname : '/[id]' ,
69
+ query : { id : snippetId } ,
70
+ } ,
71
+ snippetPath ,
72
+ {
73
+ shallow : true ,
74
+ scroll : false
75
+ }
76
+ )
65
77
} , [ snippetId , props . router ] )
66
78
67
79
function onEditorUpdate ( state ) {
You can’t perform that action at this time.
0 commit comments