I found the answer. Each prop is an object with a ‘status’ property, which will eventually be set to ‘visible'.
So the best place for initialisation based on props (e.g. contacting a remote server) is probably in componentDidUpdate rather than componentDidMount, checking the value of ‘status’ before doing work….
It would be good if stuff like this was documented – the ‘pluggable widget’ documentation is incredibly thin….
Perhaps you could do this with async and await. This way the function would await result
https://www.valentinog.com/blog/await-react/
async componentDidMount() {
const response = await fetch('link');
const json = await response.json();
this.setState({ data: json });
}
Hi James,
The typings are found in https://www.npmjs.com/package/mendix
There is you can find the hint on the API
there .status in the attribute, that can have a value: loading, unavailable, available
Reference documentation is on its way, we plan to ship when Mx8 GA is released. For now there is only the how to https://docs.mendix.com/howto/extensibility/pluggable-widgets
Cheers, Andries