From 0cb0af2caeef5ccf8cc146d1eee319c5513406f6 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 9 Mar 2018 21:11:28 +0200 Subject: [PATCH] fix: make ReactStandalone react on props changes --- src/components/StoreProvider.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/StoreProvider.ts b/src/components/StoreProvider.ts index 3d5f332e05..1bb3547736 100644 --- a/src/components/StoreProvider.ts +++ b/src/components/StoreProvider.ts @@ -3,6 +3,7 @@ import { Component } from 'react'; import { AppStore } from '../services/'; import { RedocRawOptions } from '../services/RedocNormalizedOptions'; import { loadAndBundleSpec } from '../utils'; +import { OpenAPISpec } from '../types'; interface StoreProviderProps { specUrl?: string; @@ -23,6 +24,8 @@ interface StoreProviderState { export class StoreProvider extends Component { store: AppStore; + private _resolvedSpec: OpenAPISpec; + constructor(props: StoreProviderProps) { super(props); @@ -43,10 +46,21 @@ export class StoreProvider extends Component this.load(), 0); + return; + } + if (this.props.options !== nextProps.options && this._resolvedSpec) { + this.updateStore(this._resolvedSpec, nextProps.specUrl, nextProps.options); + } + } + setError(e?: Error) { this.setState({ error: e,