Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@rc-component/portal": "^2.0.0",
"@rc-component/trigger": "^3.0.0",
"@rc-component/util": "^1.2.1",
"@rc-component/util": "^1.3.0",
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

请确认 1.3.0 是否导出 useControlledState 路径

此处升级为使用 @rc-component/util@^1.3.0 以引入 useControlledState。为避免发布后 CI 失败,请核对是否确实存在导出路径 @rc-component/util/lib/hooks/useControlledState,并与本仓库的 TS 配置兼容。


🌐 Web query:

Does @rc-component/util@1.3.0 export a module at '@rc-component/util/lib/hooks/useControlledState'? Provide a link to the file on unpkg/jsDelivr/GitHub.

💡 Result:

Short answer: No — @rc-component/util@1.3.0 does not export a module at "@rc-component/util/lib/hooks/useControlledState". The package (repo: react-component/util) exposes hooks such as useMergedState (e.g. rc-util/lib/hooks/useMergedState) rather than a useControlledState file. See the package page and repository below for the files/tree.

Sources:
[1] jsDelivr package page for @rc-component/util (shows v1.3.0 exists). [2] GitHub repository file tree for react-component/util. [3] unpkg listing showing hooks include useMergedState (not useControlledState).


修复无效的 useControlledState 导入路径

在 @rc-component/util@1.3.0 中并不存在 lib/hooks/useControlledState 模块,使用该路径会导致编译或运行时错误。可选方案:

  • 将相关导入改为 @rc-component/util/lib/hooks/useMergedState
  • 或升级到包含 useControlledState 导出的更高版本

请根据项目需求修正 package.json 依赖版本或调整代码中的导入路径。

🤖 Prompt for AI Agents
In package.json around line 45, the dependency "@rc-component/util": "^1.3.0" is
pointing to a version that does not export lib/hooks/useControlledState which
causes compile/runtime failures; fix by either updating this dependency to a
later version that re-exports useControlledState (bump the version in
package.json and run install) or, if you prefer not to upgrade, change all code
imports that reference "@rc-component/util/lib/hooks/useControlledState" to use
"@rc-component/util/lib/hooks/useMergedState" (or the public exported API) and
run a full rebuild to verify no other missing imports remain.

"classnames": "^2.3.2"
},
"devDependencies": {
Expand All @@ -63,7 +63,8 @@
"rc-test": "^7.1.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"@types/minimatch": "^5.1.2"
},
"peerDependencies": {
"react": ">=16.9.0",
Expand Down
21 changes: 10 additions & 11 deletions src/Tour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Trigger from '@rc-component/trigger';
import classNames from 'classnames';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
import { useMemo } from 'react';
import { useClosable } from './hooks/useClosable';
import useTarget from './hooks/useTarget';
Expand Down Expand Up @@ -63,18 +64,16 @@ const Tour: React.FC<TourProps> = props => {

const triggerRef = React.useRef<TriggerRef>();

const [mergedCurrent, setMergedCurrent] = useMergedState(0, {
value: current,
defaultValue: defaultCurrent,
});
const [mergedCurrent, setMergedCurrent] = useControlledState(
defaultCurrent || 0,
current,
);

const [mergedOpen, setMergedOpen] = useMergedState(defaultOpen, {
value: open,
postState: origin =>
mergedCurrent < 0 || mergedCurrent >= steps.length
? false
: (origin ?? true),
});
const [internalOpen, setMergedOpen] = useControlledState(defaultOpen, open);
const mergedOpen =
mergedCurrent < 0 || mergedCurrent >= steps.length
? false
: (internalOpen ?? true);

// Record if already rended in the DOM to avoid `findDOMNode` issue
const [hasOpened, setHasOpened] = React.useState(mergedOpen);
Expand Down
24 changes: 6 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
"@@/*": [
".dumi/tmp/*"
],
"@rc-component/tour": [
"src/Tour.tsx"
]
"@/*": ["src/*"],
"@@/*": [".dumi/tmp/*"],
"@rc-component/tour": ["src/Tour.tsx"]
}
},
"include": [
".dumirc.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
"include": [".dumirc.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}