@brightleaf/react-hooks
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "@brightleaf/react-hooks", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Useful react hooks", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -17,3 +17,3 @@ # Brightleaf React Hooks | ||
import React, { useState } from 'react' | ||
import { useGraphQL } from '@brightleaf/hooks' | ||
import { useGraphQL } from '@brightleaf/react-hooks' | ||
@@ -47,3 +47,3 @@ export default () => { | ||
import { Button, Form, TextBox } from 'react-form-elements' | ||
import { usePost } from '@brightleaf/hooks' | ||
import { usePost } from '@brightleaf/react-hooks' | ||
@@ -116,2 +116,41 @@ export default () => { | ||
) | ||
} | ||
} | ||
``` | ||
## Click Outside Hook | ||
```javascript | ||
import React, { useState, useRef } from 'react' | ||
import { useClickOutside } from '@brightleaf/react-hooks' | ||
export default () => { | ||
const [menu, setMenu] = useState(false) | ||
const navMenu Ref= useRef() | ||
const hideDropDown = () => { | ||
setMenu(false) | ||
} | ||
useClickOutside(navMenu, hideDropDowns, menu) | ||
return ( | ||
<div className="App"> | ||
<nav ref={navMenu}> | ||
<div className={`dropdown ${menu ? 'active' : ' '}`}> | ||
<button | ||
type="button" | ||
className="dropdown-trigger" | ||
onClick={e => { | ||
setMenu(!ddG) | ||
}} | ||
> | ||
Menu | ||
</button> | ||
<div> | ||
...// items | ||
</div> | ||
</div> | ||
</nav> | ||
... // rest of page | ||
</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
16184
154