Hey i am using this npm package https://www.npmjs.com/package/react-cookie-consent for creating a cookies consent in my react type script app now and through this package i can store some data in cookies after user permission. Now there are two problems first it is storing after clicking on accept button it stores two object in cookies, second the change in cookies is not showing immediately in application tab in cookies section i had to reload to see the changes.
Here is my code
import React, {FC} from 'react'
import CookieConsent from "react-cookie-consent";
const CookiesBar : FC<any> = ({closeCookieBar}) => {
const lang = localStorage.getItem('language');
return (
<CookieConsent
location="bottom"
enableDeclineButton
buttonText="I understand"
declineButtonText="Decline"
style={{ background: "#2B373B" }}
cookieName="language"
cookieValue={`${lang}`}
buttonStyle={{ color: "#4e503b", fontSize: "13px" }}
declineButtonStyle={{ fontSize: "13px" }}
setDeclineCookie={false}
onAccept={({ acceptedByScrolling }) => {
if (!acceptedByScrolling) {
closeCookieBar();
}
}}
onDecline={() => closeCookieBar()}
>
This website uses cookies to enhance the user experience.{" "}
</CookieConsent>
)
}
export default CookiesBar;
I had read their own documentation and tried research and read many articles but nothing help so far.