Table of Contents
关于重现
所谓『重现』,就是一段可以运行并展示一个 bug 如何发生的代码。
我们深知你一定遇到了问题,但请先帮助我们也看到
我们非常确信你一定在本地环境上遇到了预期外的问题,可惜大多数情况我们没有办法直接站在你的屏幕边上看到这个问题,我们需要尝试在自己的环境中重现同类场景,才能帮助我们理解问题本身,以及你的预期是否和我们的预期是一致的,这些信息对于问题解决是非常关键的。在我们解决你的问题之前,你需要先帮助我们把问题和相关代码原样重现出来。
文字是不够的
如果你遇到一个问题,但是只提供了一些文字描述,我们很可能无法修复这个 bug 的。首先,文字在描述技术问题时的表达难度和不精确性;其次,问题的真实原因有很多可能,它完全有可能是一个你根本没有提及的因素导致的。重现是唯一能够可靠地让我们理解问题本质的方式。
重现必须是可运行的
截图和视频不是重现。它们仅仅证明了 bug 的存在,但却不能提供关于 bug 是如何发生的信息。只有可运行的代码提供了完整的上下文,并让我们可以进行真正的 debug 而不是空想和猜测。当然,在提供的重现的前提下,视频或是 gif 动画可以帮助解释一些比较难用文字描述的交互行为。
重现应当尽量精简
有些用户会直接给我们一整个项目的代码,然后希望我们帮忙找出问题所在。此类请求我们通常不予接受,因为:
- 你对你的项目的代码结构可能已经非常熟悉,但我们并不是。阅读、运行、分析一个完全陌生的项目是极其耗费时间和精力的。
- 由于涉及了大量业务代码,问题可能是你的代码错误,而不是 antd 的 bug 所导致的。
- 原始业务代码可能包含了商业私密信息,多数情况下是不应该公开传播的。
一个最小化的重现意味着它精确地定位了 bug 本身 - 它应当只包含能够触发 bug 的最少量的代码。你应当尽可能地剔除任何跟该 bug 无关的部分。
如何提供一个重现
除非你的 bug 只有在构建工具下才能重现,否则我们建议使用在线演示工具 来提供重现。如果你的 bug 必须用到构建工具,那么我们建议使用 create-react-app 来搭建一个新项目,推送到 GitHub 并提供仓库的链接。
What is a Minimal Reproduction, and Why is it Necessary?
About Reproduction
Reproduction is a piece of code that can be executed to show how a bug occurs.
We Understand Your Issue, But Please Help Us See It Too
We are confident that you have encountered unexpected issues in your local environment. However, we usually cannot observe the issue directly from your screen. To help us understand the problem and ensure our expectations align, we need to reproduce the same scenario in our environment. This information is critical for resolving the issue. Before we can solve your problem, you need to help us recreate the issue along with the relevant code.
Words Are Not Enough
If you encounter an issue and only provide a textual description, it is unlikely that we can fix the bug. Textual descriptions can be challenging and imprecise when explaining technical problems. The true cause of the issue could be due to factors you have not mentioned. Reproduction is the only reliable way to understand the essence of the problem.
Reproduction Must Be Runnable
Screenshots and videos are not reproductions. They only confirm the existence of a bug but do not provide information on how it occurs. Only runnable code provides the full context, enabling us to perform actual debugging instead of speculation. Of course, videos or GIFs can help explain complex interactions that are hard to describe in text, provided they accompany a reproducible example.
Reproduction Should Be Minimal
Some users send us the entire project's code, hoping we can identify the issue. We typically do not accept such requests because:
- You are familiar with your project's code structure, but we are not. Analyzing an unfamiliar project is extremely time-consuming and resource-intensive.
- The issue may stem from your code rather than an antd bug.
- Original business code may contain confidential commercial information that should not be publicly shared.
A minimal reproduction precisely isolates the bug—include only the minimum amount of code necessary to trigger the bug. Remove any parts unrelated to the bug.
How to Provide a Reproduction
Unless your bug can only be reproduced in a build tool, we recommend using an online demo tool to provide a reproduction. If your bug requires a build tool, we suggest setting up a new project with create-react-app, pushing it to GitHub, and providing the repository link.
- Home
- Cookbook
- FAQ
- Template for Bug Report in IE8 9
- Contributing
- Maintaining
- Design