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>
 
 

Was this post helpful?

2 comments

Sort by
  • Official comment
    Avatar

    Michael 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:

     

    data-no-reviews="collapse"

     

    Let us know if this does the trick for you!

     

    Cheers,
    Michael

    1
  • Avatar

    Mohan K

    Hi Michael Cohen,

    It is working awesomely.

    Thank you so much 🙂

     

    Kind regards,
    Mohanraj K

     

     

    0
Please sign in to leave a comment.