Skip to content

Commit cdabcfa

Browse files
authored
Refer other solutions
1 parent 44a44c4 commit cdabcfa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const MergedComponent = React.forwardRef((props, ref) => {
133133
})
134134
```
135135

136+
💡 - `useMergeRefs` will always give you the same return, and you don't have to worry about `[localRef, ref]` unique every render.
137+
136138
## mergeRefs
137139
`mergeRefs(refs: arrayOfRefs, [defaultValue]):ReactMutableRef` - merges a few refs together
138140
is a non-hook based version. Will produce the new `ref` every run, causing the old one to unmount, and be _populated_ with the `null` value.
@@ -141,9 +143,13 @@ is a non-hook based version. Will produce the new `ref` every run, causing the o
141143
142144
`mergeRefs` are "safe" to use as a part of other hooks-based commands, but don't forget - it returns a new object every call.
143145

144-
## Is it a rocket science?
146+
# Similar packages:
147+
- [apply-ref](https://github.com/mitchellhamilton/apply-ref) - `applyRefs` is simular to `mergeRef`, `applyRef` is similar to `assignRef`
148+
- [useForkRef](https://react-hooks.org/docs/use-fork-ref) - `useForkRef` is simular to `useMergeRefs`, but accepts only two arguments.
149+
150+
---
145151

146-
No, `RefObject` is no more than `{current: ref}`, and `use-callback-ref` is no more than `getter` and `setter` on that field.
152+
> Is it a rocket science? No, `RefObject` is no more than `{current: ref}`, and `use-callback-ref` is no more than `getter` and `setter` on that field.
147153
148154
# License
149155
MIT

0 commit comments

Comments
 (0)