Reading filedocument inside a native custom widget

Hi, I am trying to read filedocument from Mendix to a custom native widget. But the file data is not loaded to component by the time it renders. And the props value shows “status : loading and value: undefined”. How do I make sure the data is available inside the component before rendering? Any help/feedback appreciated. the code snippet and log
1 answers

The most important thing to realize here is that the React lifecycle functions (like render) are called any time a prop or state changes on the component. You could say the component reacts (heh) to changes in your data.

That applies for when data goes from a “loading” state to being “available” or for any other changes to the data. So, remember that the render function may run before your data is available, but you can also trust that it will run after.

So in the render function, you should be checking the status attribute of the object to see if it’s ready. If it’s not ready, you can return null or a loading indicator. Once the data becomes ready, render will fire again.