diff --git a/releases/next/docs/animated.html b/releases/next/docs/animated.html index 78910aa569b..43133ee9584 100644 --- a/releases/next/docs/animated.html +++ b/releases/next/docs/animated.html @@ -101,8 +101,11 @@ of the animations is stopped, they will all be stopped. You can override this with the stopTogether flag.

static stagger(time, animations) #

Array of animations may run in parallel (overlap), but are started in sequence with successive delays. Nice for doing trailing effects.

static loop(animation) #

Loops a given animation continuously, so that each time it reaches the end, it resets and begins again from the start. Can specify number of -times to loop using the key 'iterations' in the config. Will loop without -blocking the UI thread if the child animation is set to 'useNativeDriver'.

static event(argMapping, config?) #

Takes an array of mappings and extracts values from each arg accordingly, +times to loop using the key iterations in the config. Will loop without +blocking the UI thread if the child animation is set to useNativeDriver: true. +In addition, loops can prevent VirtualizedList-based components from rendering +more rows while the animation is running. You can pass isInteraction: false in the +child animation config to fix this.

static event(argMapping, config?) #

Takes an array of mappings and extracts values from each arg accordingly, then calls setValue on the mapped outputs. e.g.

onScroll={Animated.event( [{nativeEvent: {contentOffset: {x: this._scrollX}}}], {listener: (event) => console.log(event)}, // Optional async listener diff --git a/releases/next/docs/animations.html b/releases/next/docs/animations.html index 432cb8e3f4a..f36f0afe1db 100644 --- a/releases/next/docs/animations.html +++ b/releases/next/docs/animations.html @@ -192,7 +192,7 @@ You can also take a look at the Bear in mind #

While using transform styles such as rotateY, rotateX, and others ensure the transform style perspective is in place. +This means it does not work with PanResponder but does work with things like ScrollView#onScroll.

When an animation is running, it can prevent VirtualizedList components from rendering more rows. If you need to run a long or looping animation while the user is scrolling through a list, you can use isInteraction: false in your animation's config to prevent this issue.

Bear in mind #

While using transform styles such as rotateY, rotateX, and others ensure the transform style perspective is in place. At this time some animations may not render on Android without it. Example below.

<Animated.View style={{ transform: [ diff --git a/releases/next/docs/contributing.html b/releases/next/docs/contributing.html index 3a29a751fca..dc0b4d60bf9 100644 --- a/releases/next/docs/contributing.html +++ b/releases/next/docs/contributing.html @@ -1,4 +1,4 @@ -How to Contribute - React Native

How to Contribute #

React Native is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody using Facebook's mobile apps. If you're interested in contributing to React Native, hopefully this document makes the process for contributing clear.

Code of Conduct #

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Get involved #

There are many ways to contribute to React Native, and many of them do not involve writing any code. Here's a few ideas to get started:

  • Simply start using React Native. Go through the Getting Started guide. Does everything work as expected? If not, we're always looking for improvements. Let us know by opening an issue.
  • Look through the open issues. Provide workarounds, ask for clarification, or suggest labels. Help triage issues.
  • If you find an issue you would like to fix, open a pull request. Issues tagged as Good First Task are a good place to get started.
  • Read through the React Native docs. If you find anything that is confusing or can be improved, you can make edits by clicking "Improve this page" at the bottom of most docs.
  • Browse Stack Overflow and answer questions. This will help you get familiarized with common pitfalls or misunderstandings, which can be useful when contributing updates to the documentation.
  • Take a look at the features requested by others in the community and consider opening a pull request if you see something you want to work on.

Contributions are very welcome. If you think you need help planning your contribution, please hop into #react-native and let people know you're looking for a mentor.

Core contributors to React Native meet monthly and post their meeting notes on the React Native blog. You can also find ad hoc discussions in the React Native Core Contributors Facebook group.

Triaging issues and pull requests #

One great way you can contribute to the project without writing any code is to help triage issues and pull requests as they come in.

  • Ask for more information if the issue does not provide all the details required by the template.
  • Suggest labels that can help categorize issues.
  • Flag issues that are stale or that should be closed.
  • Ask for test plans and review code.

You can learn more about handling issues in the maintainer's guide.

Our development process #

Some of the core team will be working directly on GitHub. These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.

When a change made on GitHub is approved, it will first be imported into Facebook's internal source control. The change will eventually sync back to GitHub as a single commit once it has passed all internal tests.

Branch organization #

We will do our best to keep master in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to communicate these changes and version appropriately so you can lock into a specific version if need be.

To see what changes are coming and provide better feedback to React Native contributors, use the latest release candidate when possible. By the time a release candidate is released, the changes it contains will have been shipped in production Facebook apps for over two weeks.

Bugs #

We use GitHub Issues for our public bugs. If you would like to report a problem, take a look around and see if someone already opened an issue about it. If you a are certain this is a new, unreported bug, you can submit a bug report.

If you have questions about using React Native, the Community page list various resources that should help you get started.

We also have a place where you can request features or enhancements. If you see anything you'd like to be implemented, vote it up and explain your use case.

Reporting new issues #

When opening a new issue, always make sure to fill out the issue template. This step is very important! Not doing so may result in your issue getting closed. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.

  • One issue, one bug: Please report a single bug per issue.
  • Provide a Snack: The best way to get attention on your issue is to provide a reduced test case. You can use Snack to demonstrate the issue.
  • Provide reproduction steps: List all the steps necessary to reproduce the issue. Provide a Snack or upload a sample project to GitHub. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort.
  • Try out the latest version: Verify that the issue can be reproduced locally by updating your project to use React Native from master. The bug may have already been fixed!

We're not able to provide support through GitHub Issues. If you're looking for help with your code, consider asking on Stack Overflow or reaching out to the community through other channels.

Security bugs #

Facebook has a bounty program for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.

Pull requests #

Your first pull request #

So you have decided to contribute code back to upstream by opening a pull request. You've invested a good chunk of time, and we appreciate it. We will do our best to work with you and get the PR looked at.

Working on your first Pull Request? You can learn how from this free video series:

How to Contribute to an Open Source Project on GitHub

We have a list of beginner friendly issues to help you get your feet wet in the React Native codebase and familiar with our contribution process. This is a great place to get started.

Proposing a change #

If you would like to request a new feature or enhancement but are not yet thinking about opening a pull request, we have a place to track feature requests.

If you intend to change the public API, or make any non-trivial changes to the implementation, we recommend filing an issue that includes [Proposal] in the title. This lets us reach an agreement on your proposal before you put significant effort into it. These types of issues should be rare. If you have been contributing to the project long enough, you will probably already have access to the React Native Core Contributors Facebook Group, where this sort of discussion is usually held.

If you're only fixing a bug, it's fine to submit a pull request right away but we still recommend to file an issue detailing what you're fixing. This is helpful in case we don't accept that specific fix but want to keep track of the issue.

Sending a pull request #

Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

Before submitting a pull request, please make sure the following is done:

  1. Fork the repository and create your branch from master.
  2. Add the copyright notice to the top of any new files you've added.
  3. Describe your test plan in your commit.
  4. Ensure tests pass on both Travis and Circle CI.
  5. Make sure your code lints (npm run lint).
  6. If you haven't already, sign the CLA.

All pull requests should be opened against the master branch.

Note: It is not necessary to keep clicking Merge master to your branch on the PR page. You would want to merge master if there are conflicts or tests are failing. The Facebook-GitHub-Bot ultimately squashes all commits to a single one before merging your PR.

Test plan #

A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website.

  • If you've added code that should be tested, add tests!
  • If you've changed APIs, update the documentation.
  • If you've updated the docs, verify the website locally and submit screenshots if applicable (see website/README.md)

See What is a Test Plan? to learn more.

Continuous integration tests #

Make sure all tests pass on both Travis and Circle CI. PRs that break tests are unlikely to be merged. Learn more about testing your changes here.

Breaking changes #

When adding a new breaking change, follow this template in your pull request:

### New breaking change here +How to Contribute - React Native

How to Contribute #

React Native is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody using Facebook's mobile apps. If you're interested in contributing to React Native, hopefully this document makes the process for contributing clear.

Code of Conduct #

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Get involved #

There are many ways to contribute to React Native, and many of them do not involve writing any code. Here's a few ideas to get started:

  • Simply start using React Native. Go through the Getting Started guide. Does everything work as expected? If not, we're always looking for improvements. Let us know by opening an issue.
  • Look through the open issues. Provide workarounds, ask for clarification, or suggest labels. Help triage issues.
  • If you find an issue you would like to fix, open a pull request. Issues tagged as Good First Task are a good place to get started.
  • Read through the React Native docs. If you find anything that is confusing or can be improved, you can make edits by clicking "Improve this page" at the bottom of most docs.
  • Browse Stack Overflow and answer questions. This will help you get familiarized with common pitfalls or misunderstandings, which can be useful when contributing updates to the documentation.
  • Take a look at the features requested by others in the community and consider opening a pull request if you see something you want to work on.

Contributions are very welcome. If you think you need help planning your contribution, please hop into #react-native and let people know you're looking for a mentor.

Core contributors to React Native meet monthly and post their meeting notes on the React Native blog. You can also find ad hoc discussions in the React Native Core Contributors Facebook group.

Triaging issues and pull requests #

One great way you can contribute to the project without writing any code is to help triage issues and pull requests as they come in.

  • Ask for more information if the issue does not provide all the details required by the template.
  • Suggest labels that can help categorize issues.
  • Flag issues that are stale or that should be closed.
  • Ask for test plans and review code.

You can learn more about handling issues in the maintainer's guide.

Our development process #

Some of the core team will be working directly on GitHub. These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.

When a change made on GitHub is approved, it will first be imported into Facebook's internal source control. The change will eventually sync back to GitHub as a single commit once it has passed all internal tests.

Branch organization #

We will do our best to keep master in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to communicate these changes and version appropriately so you can lock into a specific version if need be.

To see what changes are coming and provide better feedback to React Native contributors, use the latest release candidate when possible. By the time a release candidate is released, the changes it contains will have been shipped in production Facebook apps for over two weeks.

Bugs #

We use GitHub Issues for our public bugs. If you would like to report a problem, take a look around and see if someone already opened an issue about it. If you a are certain this is a new, unreported bug, you can submit a bug report.

If you have questions about using React Native, the Community page list various resources that should help you get started.

We also have a place where you can request features or enhancements. If you see anything you'd like to be implemented, vote it up and explain your use case.

Reporting new issues #

When opening a new issue, always make sure to fill out the issue template. This step is very important! Not doing so may result in your issue getting closed. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.

  • One issue, one bug: Please report a single bug per issue.
  • Provide a Snack: The best way to get attention on your issue is to provide a reduced test case. You can use Snack to demonstrate the issue.
  • Provide reproduction steps: List all the steps necessary to reproduce the issue. Provide a Snack or upload a sample project to GitHub. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort.
  • Try out the latest version: Verify that the issue can be reproduced locally by updating your project to use React Native from master. The bug may have already been fixed!

We're not able to provide support through GitHub Issues. If you're looking for help with your code, consider asking on Stack Overflow or reaching out to the community through other channels.

Security bugs #

Facebook has a bounty program for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.

Pull requests #

Your first pull request #

So you have decided to contribute code back to upstream by opening a pull request. You've invested a good chunk of time, and we appreciate it. We will do our best to work with you and get the PR looked at.

Working on your first Pull Request? You can learn how from this free video series:

How to Contribute to an Open Source Project on GitHub

We have a list of beginner friendly issues to help you get your feet wet in the React Native codebase and familiar with our contribution process. This is a great place to get started.

Proposing a change #

If you would like to request a new feature or enhancement but are not yet thinking about opening a pull request, we have a place to track feature requests.

If you intend to change the public API, or make any non-trivial changes to the implementation, we recommend filing an issue that includes [Proposal] in the title. This lets us reach an agreement on your proposal before you put significant effort into it. These types of issues should be rare. If you have been contributing to the project long enough, you will probably already have access to the React Native Core Contributors Facebook Group, where this sort of discussion is usually held.

If you're only fixing a bug, it's fine to submit a pull request right away but we still recommend to file an issue detailing what you're fixing. This is helpful in case we don't accept that specific fix but want to keep track of the issue.

Sending a pull request #

Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

Please make sure the following is done when submitting a pull request:

  1. Fork the repository and create your branch from master.
  2. Add the copyright notice to the top of any new files you've added.
  3. Describe your test plan in your pull request description. Make sure to test your changes!
  4. Make sure your code lints (npm run lint).
  5. If you haven't already, sign the CLA.

All pull requests should be opened against the master branch. After opening your pull request, ensure all tests pass on Circle CI. If a test fails and you believe it is unrelated to your change, leave a comment on the pull request explaining why.

Note: It is not necessary to keep clicking Merge master to your branch on the PR page. You would want to merge master if there are conflicts or tests are failing. The Facebook-GitHub-Bot ultimately squashes all commits to a single one before merging your PR.

Test plan #

A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website.

  • If you've added code that should be tested, add tests!
  • If you've changed APIs, update the documentation.
  • If you've updated the docs, verify the website locally and submit screenshots if applicable (see website/README.md)

See What is a Test Plan? to learn more.

Continuous integration tests #

Make sure all tests pass on Circle CI. PRs that break tests are unlikely to be merged. Learn more about testing your changes here.

Breaking changes #

When adding a new breaking change, follow this template in your pull request:

### New breaking change here * **Who does this affect**: * **How to migrate**: diff --git a/releases/next/docs/netinfo.html b/releases/next/docs/netinfo.html index 94149dc955f..b6f9e0be00b 100644 --- a/releases/next/docs/netinfo.html +++ b/releases/next/docs/netinfo.html @@ -38,12 +38,12 @@ internet connectivity.

NetInfofunction handleFirstConnectivityChange(isConnected) { console.log('Then, is ' + (isConnected ? 'online' : 'offline')); NetInfo.isConnected.removeEventListener( - 'change', + 'connectionChange', handleFirstConnectivityChange ); } NetInfo.isConnected.addEventListener( - 'change', + 'connectionChange', handleFirstConnectivityChange );

Connectivity Types (deprecated) #

The following connectivity types are deprecated. They're used by the deprecated APIs fetch and the change event.

iOS connectivity types (deprecated): - none - device is offline diff --git a/releases/next/docs/testing.html b/releases/next/docs/testing.html index 9bf69beb891..2fac056f186 100644 --- a/releases/next/docs/testing.html +++ b/releases/next/docs/testing.html @@ -1,11 +1,11 @@ -Testing your Changes - React Native

Testing your Changes #

This document is about testing your changes to React Native as a contributor. If you're interested in testing a React Native app, check out the React Native Tutorial on the Jest website.

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis and Circle continuous integration systems, which will automatically annotate pull requests with the test results.

Whenever you are fixing a bug or adding new functionality to React Native, you should add a test that covers it. Depending on the change you're making, there are different types of tests that may be appropriate.

JavaScript #

Jest #

Jest tests are JavaScript-only tests run on the command line with node. You can run the existing React Native jest tests with:

$ cd react-native +Testing your Changes - React Native

Testing your Changes #

This document is about testing your changes to React Native as a contributor. If you're interested in testing a React Native app, check out the React Native Tutorial on the Jest website.

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run using Circle, a continuous integration system. Circle will automatically annotate pull requests with the test results.

Whenever you are fixing a bug or adding new functionality to React Native, you should add a test that covers it. Depending on the change you're making, there are different types of tests that may be appropriate.

JavaScript #

Jest #

Jest tests are JavaScript-only tests run on the command line with node. You can run the existing React Native jest tests with:

$ cd react-native $ npm test

It's a good idea to add a Jest test when you are working on a change that only modifies JavaScript code.

The tests themselves live in the __tests__ directories of the files they test. See TouchableHighlight-test.js for a basic example.

Flow #

You should also make sure your code passes Flow tests. These can be run using:

$ cd react-native $ npm run flow

Android #

Unit Tests #

The Android unit tests do not run in an emulator. They just use a normal Java installation. The default macOS Java install is insufficient, you may need to install Java 8 (JDK8). You can type javac -version in a terminal to see what version you have:

$ javac -version javac 1.8.0_111

The version string 1.8.x_xxx corresponds to JDK 8.

You also need to install the Buck build tool.

To run the Android unit tests:

$ cd react-native $ ./scripts/run-android-local-unit-tests.sh

It's a good idea to add an Android unit test whenever you are working on code that can be tested by Java code alone. The Android unit tests live under ReactAndroid/src/tests, so you can browse through that directory for good examples of tests.

Integration Tests #

To run the integration tests, you need to install the Android NDK. See Prerequisites.

You also need to install the Buck build tool.

We recommend running the Android integration tests in an emulator, although you can also use a real Android device. It's a good idea to keep the emulator running with a visible window. That way if your tests stall, you can look at the emulator to debug.

Some devices and some emulator configurations may not work with the tests. We do maintain an emulator configuration that works, as the standard for testing. To run this emulator config:

$ cd react-native $ ./scripts/run-android-emulator.sh

Once you have an emulator running, to run the integration tests:

$ cd react-native $ ./scripts/run-android-local-integration-tests.sh

The integration tests should only take a few minutes to run on a modern developer machine.

It's a good idea to add an Android integration test whenever you are working on code that needs both JavaScript and Java to be tested in conjunction. The Android integration tests live under ReactAndroid/src/androidTest, so you can browse through that directory for good examples of tests.

iOS #

Integration Tests #

React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS as NativeModules.TestModule.

The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria.

See the following for example usage and integration points:

You can run integration tests locally with cmd+U in the IntegrationTest and RNTester apps in Xcode, or by running the following in the command line on macOS:

$ cd react-native -$ ./scripts/objc-test-ios.sh

Your Xcode install will come with a variety of Simulators running the latest OS. You may need to manually create a new Simulator to match what the XCODE_DESTINATION param in the test script.

Screenshot/Snapshot Tests #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image. To do this, simply change to _runner.recordMode = YES; in RNTester/RNTesterSnapshotTests.m, re-run the failing tests, then flip record back to NO and submit/update your PR and wait to see if the Travis build passes.

Apple TV #

The same tests discussed above for iOS will also run on tvOS. In the RNTester Xcode project, select the RNTester-tvOS target, and you can follow the same steps above to run the tests in Xcode.

You can run Apple TV unit and integration tests locally by running the following in the command line on macOS:

$ cd react-native +$ ./scripts/objc-test-ios.sh

Your Xcode install will come with a variety of Simulators running the latest OS. You may need to manually create a new Simulator to match what the XCODE_DESTINATION param in the test script.

Screenshot/Snapshot Tests #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image. To do this, simply change to _runner.recordMode = YES; in RNTester/RNTesterSnapshotTests.m, re-run the failing tests, then flip record back to NO and submit/update your PR and wait to see if the Circle build passes.

Apple TV #

The same tests discussed above for iOS will also run on tvOS. In the RNTester Xcode project, select the RNTester-tvOS target, and you can follow the same steps above to run the tests in Xcode.

You can run Apple TV unit and integration tests locally by running the following in the command line on macOS:

$ cd react-native $ ./scripts/objc-test-tvos.sh (make sure the line `TEST="test"` is uncommented)

End-to-end tests #

Finally, make sure end-to-end tests run successfully by executing the following script:

$ cd react-native $ ./scripts/test-manual-e2e.sh

Website #

The React Native website is hosted on GitHub pages and is automatically generated from Markdown sources as well as comments in the JavaScript source files. It's always a good idea to check that the website is generated properly whenever you edit the docs.

$ cd website $ npm install