forked from p15670423/monkey
cc: Don't try rendering any monkey config tab if length of `this.state.configuration` is 0
The config is fetched in `componentDidMount()` (which is called after `render()` finishes successfully). If you attempt to render the configuration (i.e. call `renderConfigContent()`) before the config is fetched, it throws an error.
This commit is contained in:
parent
917d7dfb15
commit
6e3053cfc0
|
@ -105,6 +105,7 @@ class ConfigurePageComponent extends AuthComponent {
|
|||
|
||||
componentDidMount = () => {
|
||||
let urls = [CONFIG_URL, ATTACK_URL];
|
||||
// ??? Why fetch config here and not in `render()`?
|
||||
Promise.all(urls.map(url => this.authFetch(url).then(res => res.json())))
|
||||
.then(data => {
|
||||
let sections = [];
|
||||
|
@ -521,7 +522,7 @@ class ConfigurePageComponent extends AuthComponent {
|
|||
let content = '';
|
||||
if (this.state.selectedSection === 'attack' && Object.entries(this.state.attackConfig).length !== 0) {
|
||||
content = this.renderMatrix()
|
||||
} else if (this.state.selectedSection !== 'attack') {
|
||||
} else if (this.state.selectedSection !== 'attack' && Object.entries(this.state.configuration).length !== 0) {
|
||||
content = this.renderConfigContent(displayedSchema)
|
||||
}
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue