UNPKG

641 BJavaScriptView Raw
1import { useCookies } from 'react-cookie';
2
3export function useChannelBanner() {
4 // Set display state for recommended channel banner
5 const [cookies, setCookie] = useCookies(['hideBanner']);
6
7 // If we have a hideBanner cookie, we want to hide the banner! So we will use
8 // this as the initial state for bannerIsOpen
9 const bannerIsOpen = !Boolean(cookies.hideBanner);
10 // If user interacts with channel banner, set cookie to hide it permanently
11 function hideTheBanner() {
12 setCookie('hideBanner', true, {
13 path: '/',
14 maxAge: 60 * 60 * 24 * 365 * 10
15 });
16 }
17
18 return {
19 bannerIsOpen,
20 hideTheBanner
21 };
22}