Skip to content

Commit

Permalink
chore: remove ahooks@2
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed Dec 26, 2023
1 parent 1a3b687 commit c49dd8f
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 81 deletions.
7 changes: 7 additions & 0 deletions packages/antd-plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @orca-fe/painter

## 0.3.16

### Patch Changes

- Updated dependencies
- @orca-fe/pocket@3.4.1

## 0.3.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/antd-plus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/antd-plus",
"version": "0.3.15",
"version": "0.3.16",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@orca-fe/hooks": "^1.11.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.4.0",
"@orca-fe/pocket": "^3.4.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
7 changes: 7 additions & 0 deletions packages/painter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @orca-fe/painter

## 1.4.51

### Patch Changes

- Updated dependencies
- @orca-fe/pocket@3.4.1

## 1.4.50

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/painter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/painter",
"version": "1.4.50",
"version": "1.4.51",
"description": "Konva Painter",
"keywords": [
"react",
Expand Down Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@orca-fe/hooks": "^1.11.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.4.0",
"@orca-fe/pocket": "^3.4.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
8 changes: 8 additions & 0 deletions packages/pdf-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @orca-fe/pdf-viewer

## 1.21.4

### Patch Changes

- Updated dependencies
- @orca-fe/pocket@3.4.1
- @orca-fe/painter@1.4.51

## 1.21.3

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/pdf-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pdf-viewer",
"version": "1.21.3",
"version": "1.21.4",
"description": "PDF Viewer",
"keywords": [
"react",
Expand Down Expand Up @@ -40,9 +40,9 @@
"dependencies": {
"@orca-fe/hooks": "^1.11.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/painter": "^1.4.50",
"@orca-fe/painter": "^1.4.51",
"@orca-fe/pdfjs-dist-browserify": "^3.8.24",
"@orca-fe/pocket": "^3.4.0",
"@orca-fe/pocket": "^3.4.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/pocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/pocket

## 3.4.1

### Patch Changes

- chore: remove ahooks@2

## 3.4.0

### Minor Changes
Expand Down
3 changes: 1 addition & 2 deletions packages/pocket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pocket",
"version": "3.4.0",
"version": "3.4.1",
"description": "UI components by orca-team",
"keywords": [
"react",
Expand Down Expand Up @@ -45,7 +45,6 @@
"@rc-component/trigger": "^1.13.3",
"@types/react-window": "^1.8.5",
"ahooks": "^3.7.8",
"ahooks-v2": "^2.10.15",
"classnames": "^2.3.2",
"copy-to-clipboard": "^3.3.3",
"events": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/pocket/src/context-menu/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ForwardedRef, ReactNode } from 'react';
import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
import { Transition } from 'react-transition-group';
import { useBoolean, useClickAway, useEventListener } from 'ahooks-v2';
import { useBoolean, useClickAway, useEventListener } from 'ahooks';
import ReactDOM from 'react-dom';
import cn from 'classnames';
import { useMergedRefs } from '@orca-fe/hooks';
Expand Down
4 changes: 2 additions & 2 deletions packages/pocket/src/eq-ratio-box/EqRatioBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CSSProperties } from 'react';
import React, { useEffect, useMemo, useRef } from 'react';
import { useSize } from 'ahooks-v2';
import { useSize } from 'ahooks';
import useStyles from './EqRatioBox.style';
import EqRatioBoxContext, { useRatio } from './EqRatioBoxContext';

Expand Down Expand Up @@ -33,7 +33,7 @@ const EqRatioBox = (props: EqRatioBoxProps) => {
} = props;
const styles = useStyles();
const rootRef = useRef<HTMLDivElement>(null);
const { width: containerWidth, height: containerHeight } = useSize(rootRef);
const { width: containerWidth, height: containerHeight } = useSize(rootRef) || {};

const hasSize = containerWidth != null && containerHeight != null;

Expand Down
14 changes: 6 additions & 8 deletions packages/pocket/src/menu-layout/useUniqArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemoizedFn } from 'ahooks';
import { useState } from 'react';
import { usePersistFn } from 'ahooks-v2';

type UseUniqArrayResult<T> = [
T[],
Expand All @@ -10,20 +10,18 @@ type UseUniqArrayResult<T> = [
},
];

export default function useUniqArray<T>(
defaultArr: T[] = [],
): UseUniqArrayResult<T> {
export default function useUniqArray<T>(defaultArr: T[] = []): UseUniqArrayResult<T> {
const [arr, setArr] = useState<T[]>(defaultArr);

const add = usePersistFn((item: T) => {
const has = arr.findIndex((i) => i === item) >= 0;
const add = useMemoizedFn((item: T) => {
const has = arr.findIndex(i => i === item) >= 0;
if (!has) {
setArr([...arr, item]);
}
});

const remove = usePersistFn((item: T) => {
const index = arr.findIndex((i) => i === item);
const remove = useMemoizedFn((item: T) => {
const index = arr.findIndex(i => i === item);
if (index >= 0) {
const newArr = [...arr];
newArr.splice(index, 1);
Expand Down
4 changes: 2 additions & 2 deletions packages/pocket/src/open-box/OpenBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMount, usePersistFn, useUpdateEffect } from 'ahooks-v2';
import { useMount, useMemoizedFn, useUpdateEffect } from 'ahooks';
import React, { useImperativeHandle, useRef } from 'react';
import useStyles from './OpenBox.style';

Expand Down Expand Up @@ -59,7 +59,7 @@ const OpenBox: React.FC<OpenBoxProps> = React.forwardRef((props, pRef) => {
}
}, [open]);

const handleTransitionEnd = usePersistFn(() => {
const handleTransitionEnd = useMemoizedFn(() => {
if (ref.current) ref.current.style.height = open ? '' : `${height}px`;
});
return (
Expand Down
6 changes: 2 additions & 4 deletions packages/pocket/src/react-script/ReactScript.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { usePrevious } from 'ahooks-v2';
import { usePrevious } from 'ahooks';
import { eq } from 'lodash-es';
import type React from 'react';
import { useEffect, useState } from 'react';
Expand Down Expand Up @@ -29,9 +29,7 @@ const ReactScript = (props: ReactScriptProps) => {
useEffect(() => {
if (!eq(src, prevSrc)) {
const srcList = Array.isArray(src) ? src : [src];
Promise.all(
srcList.map((src) => loadScript(src).catch(handleError)),
).then(handleLoad);
Promise.all(srcList.map(src => loadScript(src).catch(handleError))).then(handleLoad);
}
}, [src]);
return (loaded && children) as React.ReactElement;
Expand Down
7 changes: 2 additions & 5 deletions packages/pocket/src/should-update/demo/Demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { shouldUpdate } from '@orca-fe/pocket';
import { useInterval } from 'ahooks-v2';
import { useInterval } from 'ahooks';

const MyComponent = (props: { num: number }) => {
const { num = 1 } = props;
Expand All @@ -13,10 +13,7 @@ const MyComponent = (props: { num: number }) => {
};

// 包裹生成一个新组件,仅在 num 属性发生变化是才重新渲染
const NotUpdateMyComponent = shouldUpdate(
MyComponent,
(props, prevProps) => props.num !== prevProps.num,
);
const NotUpdateMyComponent = shouldUpdate(MyComponent, (props, prevProps) => props.num !== prevProps.num);

const Demo = () => {
const [{ num }, setNum] = useState({ num: 0 });
Expand Down
60 changes: 10 additions & 50 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit c49dd8f

@vercel
Copy link

@vercel vercel bot commented on c49dd8f Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.