How to Hide Trustpilot widget in React if there are no reviews exist
How to hide Trustpilot widget element if there are no reviews?
This is the code I used.
<div
className="trustpilot-widget"
data-locale={locale}
ref={trustPilotRef}
data-template-id={plpTrustpilotId}
data-businessunit-id={trustpilotBuId}
data-style-height="24px"
data-style-width="100%"
data-theme="light"
data-sku={data.variantDetails && data.variantDetails[currentVariant].sku}
data-star-color="#000000"
data-text-color="#5A5A5A"
data-no-reviews="hide"
data-scroll-to-list="false"
data-style-alignment={breakpoint.name === 'sm' ? 'right' : 'left'}
></div>
2 comments
Sort by Date VotesMichael Cohen Trustpilot
Hi Mohan K,
Thanks for the question. We don't actually have this documented just yet, but the best way to achieve this is to use "collapse" as the value for the data-no-reviews parameter, like this:
Let us know if this does the trick for you!
Cheers,
Michael
Mohan K
Hi Michael Cohen,
It is working awesomely.
Thank you so much 🙂