1 | import { useRef } from 'react';
|
2 | let idCount = 0;
|
3 |
|
4 | function uniqueId(prefix) {
|
5 | return '' + ((prefix == null ? '' : prefix) + ++idCount);
|
6 | }
|
7 |
|
8 | export function notify(handler, args) {
|
9 |
|
10 | if (handler) handler.apply(null, args);
|
11 | }
|
12 | export const useInstanceId = (otherId, suffix = '') => {
|
13 | const id = useRef();
|
14 | if (!id.current) id.current = uniqueId('rw_');
|
15 | return (otherId || id.current) + suffix;
|
16 | };
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export function useFirstFocusedRender(focused, open) {
|
23 | const ref = useRef(false);
|
24 | return ref.current || (focused || !!open) && (ref.current = true);
|
25 | } |
\ | No newline at end of file |