Closed alvigr closed 2 days ago
Start a new pull request in StackBlitz Codeflow.
It seems you are experiencing an issue where the application freezes after quickly opening and closing a modal in your Ant Design project. This can happen due to asynchronous logic that might not be handled properly. Let's try to address this issue.
Debounce the Modal Actions: Implement a debounce function to ensure that the modal open and close actions are not triggered too quickly in succession. This can help prevent the application from freezing due to rapid state changes.
Check State Management: Ensure that the state management logic is correctly implemented. Rapid state changes can sometimes cause issues if the state is not updated properly.
Use useEffect
Hook: If you are using React hooks, make sure that the useEffect
hook is used correctly to handle side effects when the modal state changes.
Error Handling: Implement error handling to catch any exceptions that might occur during the asynchronous operations.
Optimize Render Logic: Ensure that the render logic is optimized and does not cause unnecessary re-renders which might lead to performance issues.
If you can share more details about the specific implementation or any error messages you are encountering, I can provide more targeted assistance.
For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.
Test React 19 working as expect. Guess 18 has some sync logic problem which need to check.
https://stackblitz.com/edit/vitejs-vite-9d5xazpn?file=package.json
After debug, find that React 18 will merge the state into one render for open
from true
to false
which make motion effect run.
I'm not sure this is a bug for React since the reproduce code has the setTimeout
which should not be auto batched.
Since for fix this will patch a state check for rc-motion
which will be a break change of CSSMotion api. I will do the fix in antd v6 instead break v5.
Reproduction link
Steps to reproduce
The issue occurs when the modal window is closed programmatically shortly after being opened using asynchronous logic.
To reproduce the issue in my example, follow these steps:
What is expected?
What is actually happening?