From 0045be0b753b8fb7d8d58a4e511783a6ba858444 Mon Sep 17 00:00:00 2001 From: Oprysk Vyacheslav Date: Tue, 19 Jul 2022 18:17:28 +0300 Subject: [PATCH] fix: Scrolling keeps rewriting url after a Redoc element was removed #2051 (#2085) --- package-lock.json | 13 ------------- src/standalone.tsx | 8 +++++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index a779927a..e4759061 100644 --- a/package-lock.json +++ b/package-lock.json @@ -97,7 +97,6 @@ "ts-node": "^10.0.0", "typescript": "~4.1.0", "unfetch": "^4.2.0", - "url-polyfill": "^1.1.12", "webpack": "^5.38.1", "webpack-cli": "^4.7.2", "webpack-dev-server": "^4.6.0", @@ -18028,12 +18027,6 @@ "querystring": "0.2.0" } }, - "node_modules/url-polyfill": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.12.tgz", - "integrity": "sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A==", - "dev": true - }, "node_modules/url-template": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", @@ -32844,12 +32837,6 @@ } } }, - "url-polyfill": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.12.tgz", - "integrity": "sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A==", - "dev": true - }, "url-template": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", diff --git a/src/standalone.tsx b/src/standalone.tsx index 1cb32cbb..3ef5892a 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { hydrate as hydrateComponent, render } from 'react-dom'; +import { hydrate as hydrateComponent, render, unmountComponentAtNode } from 'react-dom'; import { configure } from 'mobx'; import { Redoc, RedocStandalone } from './components/'; @@ -74,6 +74,12 @@ export function init( ); } +export function destroy(element: Element | null = querySelector('redoc')): void { + if (element) { + unmountComponentAtNode(element); + } +} + export function hydrate( state: StoreState, element: Element | null = querySelector('redoc'),