-
-
Notifications
You must be signed in to change notification settings - Fork 46
fix: Skip first frame render with motion appear #73
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -492,6 +492,24 @@ describe('CSSMotion', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(activeBoxNode).toHaveClass(`animation-leave-active`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('styleReady returns NONE on first mount when status is STATUS_NONE', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const mockRender = jest.fn(() => null) as jest.Mock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (mockRender as any).mock.calls = [] as any; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <CSSMotion visible motionAppear motionName="test"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {mockRender} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </CSSMotion>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+495
to
+504
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个测试的标题和注释有点误导性。该测试并未直接检查 例如: 标题: 注释:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // First render (prepare stage) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(mockRender.mock.calls[0][0]).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect.objectContaining({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className: 'test-appear test-appear-prepare test', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
495
to
511
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI 构建失败:TypeScript 类型错误 流水线报错 🔧 修复建议- const mockRender = jest.fn(() => null);
+ const mockRender = jest.fn((_props: Record<string, any>, _ref?: any) => null);或者使用类型断言: - expect(mockRender.mock.calls[0][0]).toEqual(
+ expect((mockRender.mock.calls[0] as [any, any])[0]).toEqual(📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: ✅ test[error] 505-505: Command 'bunx tsc --noEmit' failed with TS2493: Tuple type '[]' of length '0' has no element at index '0'. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| describe('immediately', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('motionLeaveImmediately', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { container } = render( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
将
styleReady设置为'NONE'的条件!mountedRef.current && currentStatus === STATUS_NONE过于宽泛。如果组件在挂载时visible={true}但motionAppear={false},这会导致组件渲染为null并且卡在这个状态。该条件应该更具体,仅适用于 "appear" 动画。它应该检查
motionAppear和visible属性,类似于为STATUS_APPEAR确定nextStatus的方式。