Skip to content

Commit acad095

Browse files
committed
main 🧊 v0.3.4
1 parent eb0b396 commit acad095

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

‎packages/core/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@siberiacancode/reactuse",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "The ultimate collection of react hooks",
55
"author": {
66
"name": "SIBERIA CAN CODE 🧊",

‎packages/core/src/utils/helpers/isTarget.ts‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { RefObject } from "react";
1+
import type { RefObject } from 'react';
22

3-
export const targetSymbol = Symbol("target");
3+
export const targetSymbol = Symbol('target');
44

55
export type Target = (() => Element) | string | Document | Element | Window;
66
interface StateRef<Value> {
@@ -18,15 +18,15 @@ export type HookTarget =
1818
};
1919

2020
const getElement = (target: HookTarget) => {
21-
if ("current" in target) {
21+
if ('current' in target) {
2222
return target.current;
2323
}
2424

25-
if (typeof target.value === "function") {
25+
if (typeof target.value === 'function') {
2626
return target.value();
2727
}
2828

29-
if (typeof target.value === "string") {
29+
if (typeof target.value === 'string') {
3030
return document.querySelector(target.value);
3131
}
3232

@@ -47,17 +47,15 @@ const getElement = (target: HookTarget) => {
4747

4848
export const target = (target: Target) => ({
4949
value: target,
50-
type: targetSymbol,
50+
type: targetSymbol
5151
});
5252

5353
export const isTarget = (target: HookTarget) =>
54-
(typeof target === "object" &&
55-
("current" in target ||
56-
(target && (target as any).type === targetSymbol))) ||
57-
(typeof target === "function" && "state" in target && "current" in target);
54+
(typeof target === 'object' &&
55+
('current' in target || (target && (target as any).type === targetSymbol))) ||
56+
(typeof target === 'function' && 'state' in target && 'current' in target);
5857

59-
export const getRefState = (target?: HookTarget) =>
60-
target && "state" in target && target.state;
58+
export const getRefState = (target?: HookTarget) => target && 'state' in target && target.state;
6159

6260
isTarget.wrap = target;
6361
isTarget.getElement = getElement;

‎packages/core/tests/setupTests.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
if (typeof document !== "undefined") {
2-
const target = document.createElement("div");
3-
target.id = "target";
1+
if (typeof document !== 'undefined') {
2+
const target = document.createElement('div');
3+
target.id = 'target';
44
target.tabIndex = 0;
55
document.body.appendChild(target);
66
}

0 commit comments

Comments
 (0)