Why does javascript not not fire on page change in Gatsby project?

I have a trustpilot widget that renders fine on initial load. Then when i change pages, the trustpilot widget resorts back to default logo with no data showing.

I tried removing the external trustpilot js within componentDidMount, then adding it back in, to try refresh but didnt work.

I thought I could manually add in the trustpilot html again. Is there a way to do this in gatsby? and will this work? the below didnt work.

$('#trustpilot').after('<div class="trustpilot-widget trustpilot-carousel" data-locale="...

2 thoughts on “Why does javascript not not fire on page change in Gatsby project?”

Leave a Comment