144
Views
2
Comments
[Reactive Wait for Element Creation] Did you consider to use the reactJS event componentDidMount for this?
reactive-wait-for-element-creation
Reactive icon
Forge asset by José Pedro Proença
Application Type
Reactive

Hi 

I was curious to understand why you implemented this with a javascript while loop and a promise, where you can also use the ReactJS event componentDidMount on the specific OutSystems widget and an event handler.

https://www.codingame.com/playgrounds/8747/react-lifecycle-methods-render-and-componentdidmount

Regards,

Daniel

2026-03-23 09-58-51
Pedro Domingues
Champion

I agree! In our project we use a lot those React LifeCycle methods to control the rendering of the elements.

2021-01-21 14-05-49
José Pedro Proença
 
MVP

Hi Daniël Kuhlmann,

Thank you very much for the alternative solution! That's a great one, with much less complexity.

Just to give some context, we created this component, because we needed to react to the creation of an element from a "sibling" block, so we didn't have access to the Events of the element that we wanted to listen to.

In our case, we wanted to see if the fifth line of a list was present on the page in order to append a banner after it. You can find bellow how we used the Component.



I guess we could have found a workaround with your solution, however, it would be complex as well the process of sending the Event to the listening block, since it's not the parent. We have found was in the past to send events like this, but they always require some javascript.


Once again, that was a really cool insight!

Thanks for sharing it with us, and with the people looking for such a solution, like we were when we built this component. :)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.