Skip to content

Commit

Permalink
feat: export useModalize from the root of the library (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhayashi authored Aug 10, 2022
1 parent 5119f51 commit 7684f8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 15 additions & 3 deletions docs/HOOKS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Available hooks

There is a hook available to quickly access Modalize.
There is a hook available to quickly access Modalize. It returns an object with
three keys:

- `ref`: a ref object to pass to the `Modalize` component
- `open`: a function that opens the `Modalize` component. If you are using
`snapPoint` prop, you can supply a `dest` argument to the `open`
function, to open it to the top directly `open('top')`. You don't have
to provide anything if you want the default behavior.
- `close`: a function that closes the `Modalize` component. You don't need to call
it to dismiss the modal, since you can swipe down to dismiss.
If you are using `alwaysOpen` prop, you can supply a `dest` argument
to the `close` function to reset it to the initial position
`close('alwaysOpen')`, and avoiding to close it completely.

```tsx
import React, { useRef } from 'react';
import { Modalize } from 'react-native-modalize';
import React from 'react';
import { Modalize, useModalize } from 'react-native-modalize';

export const App = () => {
const { ref, open, close } = useModalize();
Expand Down
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {

import { IProps, TOpen, TClose, TStyle, IHandles, TPosition } from './options';
import { useDimensions } from './utils/use-dimensions';
import { useModalize } from './utils/use-modalize';
import { getSpringConfig } from './utils/get-spring-config';
import { isIphoneX, isIos, isAndroid } from './utils/devices';
import { isBelowRN65, isRNGH2 } from './utils/libraries';
Expand Down Expand Up @@ -1000,4 +1001,5 @@ const ModalizeBase = (

export type ModalizeProps = IProps;
export type Modalize = IHandles;
export const Modalize = React.forwardRef(ModalizeBase);
const Modalize = React.forwardRef(ModalizeBase);
export { Modalize, useModalize };

0 comments on commit 7684f8d

Please sign in to comment.