UNPKG

@darwish/hooks-core

Version:

19 lines (18 loc) 629 B
import jsCookie from 'js-cookie'; export type UseCookieOutput = [ cookieValue: string | null, updateCookie: (value: string, option?: jsCookie.CookieAttributes) => void, deleteCookie: () => void ]; /** * @description A hook to get, set and delete cookie * @param cookieName cookie name * @returns UseCookieOutput A tuple with three elements * @property UseCookieOutput[0] cookie value * @property UseCookieOutput[1] updateCookie * @property UseCookieOutput[2] deleteCookie * @example * updateCookie('cookieValue'); * deleteCookie(); */ export default function useCookie(cookieName: string): UseCookieOutput;