2.3.22 • Published 5 years ago
@tl1/utils v2.3.22
@tl1/utils
Collection of utilities. Every utility supports TypeScript and Server-side rendering.
Installation
yarn add @tl1/utils
Usage
- isSSR - Server-side rendering
- getRefElement() - Get ref element
Server-side rendering
Example
import { isSSR } from '@tl1/utils';
if (isSSR) {
console.log('SSR in action 🔥');
}
Reference
Will return a boolean that indicates if Server-side rendering is present.
const isSSR: boolean = {};
Get ref element
Example
import React, { useRef } from 'react';
import { getRefElement } from '@tl1/utils';
import React, { useRef } from 'react';
import { useTrapFocus } from '@tl1/hooks';
const Component = () => {
const ref = useRef(null);
useEffect(() => {
console.log(getRefElement(ref));
}, []);
return (
<div ref={ref} />
);
};
export default Component;
Reference
Will return element from ref. If it isn't wrapped in a ref it will return itself.
const getRefElement = <T>(
element?: RefObject<Element> | T
): Element | T | undefined | null => {};
2.3.22
5 years ago
2.3.21
5 years ago
2.3.20
5 years ago
2.3.19
5 years ago
2.3.18
5 years ago
2.3.17
5 years ago
2.3.16
5 years ago
2.3.13
5 years ago
2.3.12
5 years ago
2.3.15
5 years ago
2.3.14
5 years ago
2.3.9
5 years ago
2.3.10
5 years ago
2.3.8
5 years ago
2.3.7
5 years ago
2.3.4
5 years ago
2.3.3
5 years ago
2.3.6
5 years ago
2.3.5
5 years ago
2.3.2
5 years ago
2.3.1
5 years ago
2.3.0
5 years ago
2.1.0
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.1.0
5 years ago