@lani.ground/react-hooks
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "@lani.ground/react-hooks", | ||
"description": "react hooks", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": [ | ||
@@ -73,3 +73,3 @@ "react-hooks", | ||
}, | ||
"gitHead": "b2aeb4574a02c6eca7305d89fcaafdc1f53b835a" | ||
"gitHead": "e0b77484de036a9e7ac80eb1433442b7485a1c3b" | ||
} |
@@ -38,3 +38,2 @@ # react-hooks | ||
## useWindowScroll | ||
@@ -62,1 +61,44 @@ | ||
``` | ||
## useCookie | ||
### usage | ||
``` tsx | ||
import { useCookies } from '@lani.ground/react-hooks'; | ||
import { useEffect } from 'react'; | ||
export default function Hooks() { | ||
const { getCookie, setCookie, hasCookie, deleteCookie } = useCookies(); | ||
const setTestCookie = () => { | ||
const day = new Date(); | ||
day.setMinutes(day.getMinutes() + 1); | ||
setCookie('test', 'true', { expires: 'today' }); | ||
}; | ||
const checkCookie = () => { | ||
const hasTest = hasCookie('test'); | ||
console.log('hasTest', hasTest); // true | false | ||
}; | ||
useEffect(() => { | ||
const testCookie = getCookie('test'); | ||
console.log('testCookie', testCookie); // true | false | ||
}, []); | ||
return ( | ||
<> | ||
<button type="button" onClick={() => checkCookie()}> | ||
Check Cookie | ||
</button> | ||
<button type="button" onClick={() => setTestCookie()}> | ||
Set Cookie | ||
</button> | ||
<button type="button" onClick={() => deleteCookie('test')}> | ||
Delete Cookie | ||
</button> | ||
</> | ||
); | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19500
102