Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export useModalize from the root of the library #441

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/HOOKS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# 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 React from 'react';
import { Modalize } from 'react-native-modalize';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible to import from the root

Suggested change
import { Modalize } from 'react-native-modalize';
import { Modalize, useModalize } from 'react-native-modalize';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't work for me and I didn't see anything in the code to make it export from the index file. Happy to PR a change to have it export from there if desired

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I assume it was the case, probably missed that. You could add the export in there

import { useModalize } from 'react-native-modalize/lib/utils/use-modalize';

export const App = () => {
const { ref, open, close } = useModalize();
Expand Down