@iteam/hooks
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "@iteam/hooks", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "dist/hooks.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/hooks.esm.js", |
@@ -92,1 +92,33 @@ # Iteam Hooks | ||
``` | ||
### useLocalStorage | ||
Get and set values in `localStorage` | ||
```js | ||
useLocalStorage(key: string, initialValue?: any): [string, (newValue: string) => void] | ||
``` | ||
#### Example | ||
```js | ||
import React from 'react' | ||
import { useLocalStorage } from '@iteam/hooks' | ||
export const Storage = ({ initialValue }) => { | ||
const [value, setValue] = useLocalStorage('storedValue', initialValue) | ||
return ( | ||
<div> | ||
{value ? value : 'no value ;('} | ||
<label htmlFor="store">Update store value</label> | ||
<input | ||
id="store" | ||
onChange={e => setValue(e.currentTarget.value)} | ||
type="text" | ||
value={value} | ||
/> | ||
</div> | ||
) | ||
} | ||
``` |
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
35407
124