Skip to main content
Version: 6.x

React Navigation 贡献者指南

想要帮助改进 React Navigation?我们将非常感谢你的帮助!

¥Want to help improve React Navigation? Your help would be greatly appreciated!

以下是为该项目做出贡献的一些方法:

¥Here are some of the ways to contribute to the project:

以下是一些有助于入门的有用资源:

¥And here are a few helpful resources to aid in getting started:

贡献

¥Contributing

报告错误

¥Reporting Bugs

如果不编写偶尔出现的错误,就无法编写代码。特别是随着 React Navigation 的快速发展,错误就会发生。当你认为你已经找到了一个时,你可以执行以下操作:

¥You can't write code without writing the occasional bug. Especially as React Navigation is moving quickly, bugs happen. When you think you've found one here's what to do:

  1. 在现有问题中搜索类似你所看到的问题。如果你看到一条,请添加 👍 React(请勿 +1 评论)。仔细阅读评论,看看你是否可以向该主题提供更多有价值的信息

    ¥Search the existing issues for one like what you're seeing. If you see one, add a 👍 reaction (please no +1 comments). Read through the comments and see if you can provide any more valuable information to the thread

  2. 如果没有像你这样的其他问题,请创建一个新问题。请务必遵循 问题模板

    ¥If there are no other issues like yours then create a new one. Be sure to follow the issue template.

创造高质量的复制品至关重要。如果没有它,我们可能无法修复该错误,并且在理想情况下,你会发现它实际上并不是库的错误,而只是在你的项目中做得不正确。即时修复错误!

¥Creating a high quality reproduction is critical. Without it we likely can't fix the bug and, in an ideal situation, you'll find out that it's not actually a bug of the library but simply done incorrectly in your project. Instant bug fix!

改进文档

¥Improving the Documentation

任何成功的项目都需要高质量的文档,React Navigation 也不例外。

¥Any successful projects needs quality documentation and React Navigation is no different.

阅读有关 React-navigation/react-navigation.github.io 存储库 的文档的更多信息。

¥Read more about the documentation on the react-navigation/react-navigation.github.io repository.

回应问题

¥Responding to Issues

为 React Navigation 做出贡献的另一个好方法是响应问题。也许它正在回答某人的问题,指出他们代码中的一个小错字,或者帮助他们整理一个复制品。如果你有兴趣在 React Navigation 中扮演更积极的角色,请从响应问题开始 - 它不仅有帮助,而且展示了你对代码的承诺和知识!

¥Another great way to contribute to React Navigation is by responding to issues. Maybe it's answering someone's question, pointing out a small typo in their code, or helping them put together a reproduction. If you're interested in a more active role in React Navigation start with responding to issues - not only is it helpful but it demonstrates your commitment and knowledge of the code!

Bug 修复

¥Bug Fixes

找到错误,修复它,一整天你都会有好运!就像之前提到的那样,错误会发生。如果你发现错误,请执行以下操作:

¥Find a bug, fix it up, all day long you'll have good luck! Like it was mentioned earlier, bugs happen. If you find a bug do the following:

  1. 检查是否已存在解决该错误的拉取请求。如果确实给它一个评论并留下你的评论

    ¥Check if a pull request already exists addressing that bug. If it does give it a review and leave your comments

  2. 如果还没有拉取请求,那么找出解决方案!如果它相对较小,请继续修复它并提交拉取请求。如果更改数量相当大,请先提出问题,以便我们讨论(请参阅 大拉动请求 部分)

    ¥If there isn't already a pull request then figure out the fix! If it's relatively small go ahead and fix it and submit a pull request. If it's a decent number of changes file an issue first so we can discuss it (see the Big Pull Requests section)

  3. 如果存在与该错误相关的问题,请对其发表评论,并链接到你的拉取请求,以便其他人知道该问题已得到解决。

    ¥If there is an issue related to that bug leave a comment on it, linking to your pull request, so others know it's been addressed.

查看 把招工广告第一期好 标签,看看你可以从哪里开始提供帮助!

¥Check out the help wanted and good first issue tags to see where you can start helping out!

推荐一个功能

¥Suggesting a Feature

你想从 React Navigation 中看到什么吗?请 在 Canny 上创建功能请求

¥Is there something you want to see from React Navigation? Please create a feature request on Canny.

大拉动请求

¥Big Pull Requests

对于任何将在项目中添加/删除/修改多个文件的更改(新功能或错误修复),请立即推迟编写代码。有几个原因

¥For any changes that will add/remove/modify multiple files in the project (new features or bug fixes) hold off on writing code right away. There's a few reasons for that

  1. 大的拉取请求需要花费大量时间来审查,有时很难了解上下文

    ¥Big pull requests take a lot of time to review and it's sometimes hard to pick up the context

  2. 通常你可能不需要做出你期望的那么大的改变

    ¥Often you may not have to make as big of a change as you expect

考虑到这一点,这是建议

¥With that in mind, here's the suggestion

  1. 提出一个问题并明确定义你想要完成什么以及你打算如何完成它

    ¥Open an issue and clearly define what it is you want to accomplish and how you intend to accomplish it

  2. 与社区和维护人员讨论该解决方案。提供上下文、建立边缘案例并找出设计

    ¥Discuss that solution with the community and maintainers. Provide context, establish edge cases, and figure out the design

  3. 决定行动计划

    ¥Decide on a plan of action

  4. 编写代码并提交 PR

    ¥Write the code and submit the PR

  5. 查看 PR。这可能需要一些时间,但如果你按照上述步骤操作,希望不会花费太多时间。

    ¥Review the PR. This can take some time but, if you followed the steps above, hopefully it won't take too much time.

我们想要这样做的原因是为了节省每个人的时间。也许该功能已经存在但没有记录?或者它可能不适合库。无论如何,通过预先讨论重大变更,你可以节省自己的时间,也可以节省其他人的时间。

¥The reason we want to do this is to save everyone time. Maybe that feature already exists but isn't documented? Or maybe it doesn't fit with the library. Regardless, by discussing a major change up front you're saving your time and others time as well.

信息

¥Information

问题模板

¥Issue Template

在提交问题之前,请先查看 问题模板 并关注它。这样做是为了帮助每个人更好地了解你遇到的问题,并减少获取必要信息的时间。

¥Before submitting an issue, please take a look at the issue template and follow it. This is in place to help everyone better understand the issue you're having and reduce the back and forth to get the necessary information.

是的,完成问题模板需要时间和精力。但这是提出高质量问题并真正得到答复的唯一方法。

¥Yes, it takes time and effort to complete the issue template. But that's the only way to ask high quality questions that actually get responses.

你是否愿意花 1 分钟创建一份不完整的问题报告,然后等待数月才能得到任何类型的回复?或者你愿意花 20 分钟填写一份包含所有必要元素的高质量问题报告,并在几天内获得回复?对于任何愿意花时间审查你的问题的人来说,这也是一种尊重。

¥Would you rather take 1 minute to create an incomplete issue report and wait months to get any sort of response? Or would you rather take 20 minutes to fill out a high quality issue report, with all the necessary elements, and get a response in days? It's also a respectful thing to do for anyone willing to take the time to review your issue.

拉取请求模板

¥Pull Request Template

与问题模板非常相似,拉取请求模板 列出了说明,以确保你的拉取请求得到及时审核并减少来回。在开始编写任何代码之前,请务必仔细检查它。

¥Much like the issue template, the pull request template lays out instructions to ensure your pull request gets reviewed in a timely manner and reduces the back and forth. Make sure to look it over before you start writing any code.

分叉存储库

¥Forking the Repository

  • 在 GitHub 上分叉 repo

    ¥Fork the repo on GitHub

  • 在终端中运行以下命令以在本地下载并安装它:

    ¥Run these commands in the terminal to download locally and install it:

git clone https://github.com/<USERNAME>/navigation-ex.git
cd navigation-ex
git remote add upstream https://github.com/react-navigation/react-navigation.git
yarn

该项目对 Yarn 工作区lerna 管理的包使用 monorepo 结构。所有软件包都位于 packages/ 目录下。

¥The project uses a monorepo structure for the packages managed by yarn workspaces and lerna. All of the packages are under the packages/ directory.

代码审查指南

¥Code Review Guidelines

环视四周。与代码库其余部分的风格相匹配。该项目使用 ESLint 来确保整个项目的一致性。你可以通过运行以下命令来检查你的项目:

¥Look around. Match the style of the rest of the codebase. This project uses ESLint to ensure consistency throughout the project. You can check your project by running:

yarn lint

如果发生任何错误,你必须手动修复它们,或者可以尝试通过运行以下命令自动修复它们:

¥If any errors occur you'll either have to manually fix them or you can attempt to automatically fix them by running:

yarn lint --fix

代码库是用 TypeScript 编写的,并且必须通过类型检查。要对文件进行类型检查,请运行:

¥The codebase is written in TypeScript, and must pass typecheck. To typecheck files, run:

yarn typescript

在处理项目时,在监视模式下运行类型检查非常有用。为此,请运行:

¥It's useful to run typechecking in watch mode when working on the project. To do it, run:

yarn typescript --watch

运行示例应用

¥Run the Example App

示例应用 包含多种模式,并用作贡献者手动集成测试更改的简单方法。

¥The example app includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.

在开发过程中,你可以运行 示例应用Expo 来测试你的更改:

¥While developing, you can run the example app with Expo to test your changes:

yarn example start

运行测试

¥Run Tests

React Navigation 已在 Jest 中实现了测试。要运行其中任何一个,请从 React Navigation 目录运行以下命令之一(安装 node_modules 后)以运行测试或类型检查。

¥React Navigation has tests implemented in Jest. To run either of these, from the React Navigation directory, run either of the following commands (after installing the node_modules) to run tests or type-checking.

yarn test

在处理项目时,在监视模式下运行测试非常有用。为此,请运行:

¥It's useful to run tests in watch mode when working on the project. To do it, run:

yarn test --watch

这些命令将由我们的 CI 运行,并且需要在合并任何贡献之前通过。

¥These commands will be run by our CI and are required to pass before any contributions are merged.