@anjianshi/utils 2.8.2 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 把 emotion 的 css 函数注册为全局变量,就不用每次使用都手动引入了
3
+ */
4
+ import { css as cssValue } from '@emotion/react';
5
+ declare global {
6
+ var css: typeof cssValue;
7
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 把 emotion 的 css 函数注册为全局变量,就不用每次使用都手动引入了
3
+ */
4
+ import { css as cssValue } from '@emotion/react';
5
+ globalThis.css = cssValue;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 生成一个 ref,存储指定值并同步更新
3
+ */
4
+ export declare function useRefOfValue<T>(value: T): import("react").RefObject<T>;
5
+ /**
6
+ * 在 useState() 基础上,额外返回一个与 state 值同步的 ref
7
+ */
8
+ export declare function useStateWithRef<T>(initialValue: T | (() => T)): readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>, import("react").RefObject<T>];
@@ -0,0 +1,17 @@
1
+ import { useRef } from 'react';
2
+ /**
3
+ * 生成一个 ref,存储指定值并同步更新
4
+ */
5
+ export function useRefOfValue(value) {
6
+ const ref = useRef(value);
7
+ ref.current = value;
8
+ return ref;
9
+ }
10
+ /**
11
+ * 在 useState() 基础上,额外返回一个与 state 值同步的 ref
12
+ */
13
+ export function useStateWithRef(initialValue) {
14
+ const [state, setState] = useState(initialValue);
15
+ const ref = useRefOfValue(state);
16
+ return [state, setState, ref];
17
+ }
@@ -0,0 +1 @@
1
+ export * from './hooks.js';
@@ -0,0 +1 @@
1
+ export * from './hooks.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "2.8.2",
3
+ "version": "2.8.3",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {