-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: make ref stable #62
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #62 +/- ##
==========================================
+ Coverage 98.45% 98.47% +0.02%
==========================================
Files 11 11
Lines 388 394 +6
Branches 106 108 +2
==========================================
+ Hits 382 388 +6
Misses 6 6 ☔ View full report in Codecov by Sentry. |
Walkthrough此次变更主要对 Changes
Sequence Diagram(s)sequenceDiagram
participant P as Parent Component
participant C as CSSMotion Component
participant U as useStatus Hook
P->>C: 渲染组件并传入 ref
C->>U: 调用 useStatus 获取状态信息
U-->>C: 返回 [getStatus, ...]
C->>C: 使用 getStatus 创建 refObj (包含 dynamic inMotion)
P->>C: 通过 ref 调用 inMotion() 获取当前状态
C->>U: 执行 getStatus() 获取最新状态
U-->>C: 返回当前状态
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
src/CSSMotion.tsx
Outdated
nativeElement: getDomElement(), | ||
inMotion: () => status !== STATUS_NONE, | ||
})); | ||
const [refObj] = React.useState<CSSMotionRef>(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥不用 useMemo 大佬?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以的,改着改着就不是原来的样子了。我改成 useMemo
ref
返回 obj 时,每次 render 都会做一次fill
->null
->fill
的填充,导致和原本的渲染逻辑不一致。这里让 refObj 变成稳定态以与 rc 版本保持一致。Summary by CodeRabbit