From be09215b0569af7b4e4367a08d3bc81ca8fa1946 Mon Sep 17 00:00:00 2001 From: souvik666 Date: Thu, 26 Jan 2023 21:56:21 +0530 Subject: [PATCH] feat: packge config --- README.md | 18 ++++++++++++++++++ package.json | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4336572..61eda65 100644 --- a/README.md +++ b/README.md @@ -66,4 +66,22 @@ function MyModal() { } ``` + +## FAQ + +Q: How do I attach the returned ref to a DOM element? +A: You can attach the ref to a DOM element using the `ref` attribute. For example, if your component has a div that you want to detect clicks outside of, you can do something like this: + +```jsx +const ref = useOutsideClick(myCallback); +return
Content goes here
+``` + +Q: What is the second parameter for? +A: The second parameter is an optional boolean that indicates whether the element is open or closed. If you pass `true`, the hook will call the callback function when a click outside of the element occurs. If you pass `false`, the hook will do nothing. If you don't pass this parameter, the hook will assume that the element is always open. + +Q: Can I use this hook with a class component? +A: No, this hook can only be used in functional components. + + ## Please note that, you should use this hook in a functional component. diff --git a/package.json b/package.json index 1110da5..e8d28f6 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "@souvik666/react-auto-suggestion-input", + "name": "@souvik666/react-outside-click-hook", "version": "0.2.15", "publishConfig": { - "registry": "https://npm.pkg.github.com/react-auto-suggestion-input" + "registry": "https://npm.pkg.github.com/react-outside-click-hook" }, "description": "A simple template for a custom React component library", "scripts": { @@ -56,10 +56,10 @@ "types": "dist/index.d.ts", "repository": { "type": "git", - "url": "https://github.com/souvik666/react-auto-suggestion-input.git" + "url": "https://github.com/souvik666/react-outside-click-hook.git" }, "bugs": { - "url": "https://github.com/souvik666/react-auto-suggestion-input/issues" + "url": "https://github.com/souvik666/react-outside-click-hook.git/issues" }, "peerDependencies": { "react": ">=16.0.1",