I need to run a simple java script function after my react form has finished loading. The JS is loaded from a 3rd party so i have no control over it and i need to run one of its functions in order to make a captcha section appear in my form. If i hit F5 then the area appears as expected but navigating to the page via the routes in the app does not trigger the load.
I have worked out that if i call this line of JS
window.__challenger.callPageRequest();
Then the captcha area appears, i know this works as i added a temporary button to the form which is being render and call the funtion on the button click. But I can't have some random button, i need to just fire this JS line everytime the form is navigated to.
I've tried using:
componentDidMount() {
window.__challenger.callPageRequest();
}
But that complains with:
Cannot read property 'callPageRequest' of undefined
And i've tried adding:
window.__challenger.callPageRequest();to the end of the form in the render method.
why is it so hard to do such a simple thing? any helped would be very much appreciated.