react-drawers
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -0,1 +1,10 @@ | ||
# Version 1.4.0 | ||
24th August 2020 | ||
* **New features** | ||
* Added hooks to programmatically control drawers | ||
* **Fixes** | ||
* Fixed Layout.Switch: in some situations it could state a drawer is open even if it is closed | ||
# Version 1.3.0 | ||
@@ -2,0 +11,0 @@ 24th August 2020 |
{ | ||
"name": "react-drawers", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Collapsible docked panels for React", | ||
@@ -5,0 +5,0 @@ "author": "osioalberto@gmail.com", |
@@ -189,4 +189,24 @@ # react-drawers | ||
### Programmatic control of drawers | ||
Starting from version 1.4.0, it is possible to use some hooks to programmatically control drawers, like in the following example | ||
```jsx | ||
import { useLeftDrawer } from "react-drawers" | ||
const MyComponent = () => { | ||
const { close } = useLeftDrawer() | ||
return ( | ||
<button type="button" onClick={() => close()}>Close left drawer</button> | ||
) | ||
} | ||
``` | ||
There are four hooks (one for each drawer): `useTopDrawer`, `useRightDrawer`, `useBottomDrawer` and `useLeftDrawer`. All of them have the same return value, which consists of a JavaScript object with the following properties | ||
- `open`, function to force the drawer to open | ||
- `close`, function to force the drawer to close | ||
- `toggle`, function to toggle the drawer | ||
- `isOpen`, boolean that states if the drawer is open or closed | ||
## License | ||
MIT © [Inmagik s.r.l.](https://github.com/inmagik) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
393041
4515
212