reactjsreact-cookie-consent

How to use ButtonComponent of React-Cookie-Consent library?


Can someone advise on how to use the ButtonComponent of react-cookie-consent library. I want to add a third button on top of the accept and decline one. Looking at their documentation, there is a button component which is described as follow: ButtonComponent |React component|button |React Component to render as a button.

I have tried to use it in different ways, as a component child of the CookieConsent component <ButtonComponent/> or as props `

<CookieConsent ButtonComponent="button"
     ButtonComponentStyle={
     color: "#ffff",
     background: "#245564",
     padding: "10px 20px",
     borderRadius: "16px",
     fontSize: "1em",
     display: "flex",
     alignContent: "center",
     }>
     </CookieConsent>

None of these worked.


Solution

  • Maybe too late but I think that the solution is to add "enableDeclineButton" and "declineButtonText="Decline" ". Like this:

        <CookieConsent
            location="bottom"
            buttonText="Accept"
            cookieName="cookieName"
            enableDeclineButton
            declineButtonText="Decline"
            declineCookieValue={false}
            style={{ background: "#2EB7EB" }}
            buttonStyle={{ background:"#f5f5f5", color: "black", fontSize:"13px"}}
            declineButtonStyle={{background:"#cfcfcf", color: "black", fontSize: "13px"}}
            expires={150}> 
        </CookieConsent>