Skip to content

Commit 78b89c3

Browse files
committed
main 🧊 fix code in target page
1 parent cc5bd40 commit 78b89c3

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

‎packages/docs/app/target.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Many `React` libraries that work with DOM elements typically support only one wa
66

77
```typescript
88
const ref = useRef<HTMLDivElement>(null);
9-
useClickOutside(ref, () => console.log("Clicked outside"));
9+
useClickOutside(ref, () => console.log('Clicked outside'));
1010
```
1111

1212
This limitation forces developers to always create refs by themselves, even in cases where they might have not want to create additional refs or want to use different selection methods, like `querySelector`.
@@ -18,28 +18,29 @@ Our library implements a flexible approach using `typescript` function overloads
1818
1. By passing an **existing** target _(ref, DOM element, function that returns a DOM element, or selector)_
1919

2020
```typescript
21-
// or
22-
import { target } from "@siberiacancode/reactuse";
23-
2421
const ref = useRef<HTMLDivElement>(null);
25-
useClickOutside(ref, () => console.log("Clicked outside"));
22+
useClickOutside(ref, () => console.log('Clicked outside'));
23+
```
24+
25+
or you can use [target](#the-target-function) function
2626

27-
useClickOutside(target("#container"), () => console.log("Clicked outside"));
27+
```typescript
28+
import { target } from '@siberiacancode/reactuse';
29+
30+
useClickOutside(target('#container'), () => console.log('Clicked outside'));
2831
```
2932

3033
2. By receiving a ref callback that can be attached to an element
3134

3235
```typescript
33-
const ref = useClickOutside<HTMLDivElement>(() =>
34-
console.log("Clicked outside")
35-
);
36+
const ref = useClickOutside<HTMLDivElement>(() => console.log('Clicked outside'));
3637
```
3738

3839
This dual approach provides better developer experience and more flexibility in different use cases.
3940

40-
## The target method
41+
## The target function
4142

42-
The **target** method is a utility function that helps you work with DOM elements in a flexible way. It allows you to reference DOM elements using different approaches:
43+
The **target** function is a utility function that helps you work with DOM elements in a flexible way. It allows you to reference DOM elements using different approaches:
4344

4445
- React refs _(RefObject)_
4546
- Direct DOM elements _(Element)_
@@ -49,13 +50,13 @@ The **target** method is a utility function that helps you work with DOM element
4950
The flexibility of `target` means you can use our hooks like you want.
5051

5152
```typescript
52-
import { target } from "@siberiacancode/reactuse";
53+
import { target } from '@siberiacancode/reactuse';
5354

54-
useClickOutside(target("#container"), () => console.log("Clicked outside"));
55+
useClickOutside(target('#container'), () => console.log('Clicked outside'));
5556

5657
// or
5758

58-
useClickOutside(target(document.getElementById("#container")), () =>
59-
console.log("Clicked outside")
59+
useClickOutside(target(document.getElementById('#container')), () =>
60+
console.log('Clicked outside')
6061
);
6162
```

‎packages/docs/eslint.config.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export default eslint(
1111
name: 'siberiacancode/reactuse/md',
1212
files: ['**/*.md'],
1313
rules: {
14-
'style/max-len': 'off',
15-
'react-hooks/rules-of-hooks': 'off'
14+
'style/max-len': 'off'
1615
}
1716
},
1817
{

0 commit comments

Comments
 (0)