Skip to content

Commit a81341d

Browse files
authored
fix(swagger-ui-react): load spec on initial render (#7856)
Refs #7578
1 parent 2d4623a commit a81341d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flavors/swagger-ui-react/index.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export default class SwaggerUI extends React.Component {
4646
}
4747

4848
componentDidUpdate(prevProps) {
49-
if(this.props.url !== prevProps.url) {
49+
const prevStateUrl = this.system.specSelectors.url()
50+
if(this.props.url !== prevStateUrl || this.props.url !== prevProps.url) {
5051
// flush current content
5152
this.system.specActions.updateSpec("")
5253

@@ -58,7 +59,8 @@ export default class SwaggerUI extends React.Component {
5859
}
5960
}
6061

61-
if(this.props.spec !== prevProps.spec && this.props.spec) {
62+
const prevStateSpec = this.system.specSelectors.specStr()
63+
if(this.props.spec && (this.props.spec !== prevStateSpec || this.props.spec !== prevProps.spec)) {
6264
if(typeof this.props.spec === "object") {
6365
this.system.specActions.updateSpec(JSON.stringify(this.props.spec))
6466
} else {

0 commit comments

Comments
 (0)