diff --git a/docs/Image.md b/docs/Image.md index 2ccc915d18d835..05b6751971f81c 100644 --- a/docs/Image.md +++ b/docs/Image.md @@ -1,4 +1,4 @@ -Displaying images is a fascinating subject, React Native uses some cool tricks to make it a better experience. +Displaying images is a fascinating subject; React Native uses some cool tricks to make it a better experience. ## No Automatic Sizing diff --git a/docs/NativeModulesIOS.md b/docs/NativeModulesIOS.md index 6b204cdb3016a1..f6637a2cd25947 100644 --- a/docs/NativeModulesIOS.md +++ b/docs/NativeModulesIOS.md @@ -15,7 +15,7 @@ This is a more advanced guide that shows how to build a native module. It assume ## iOS Calendar module example -This guide will use [iOS Calendar API](https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/EventKitProgGuide/Introduction/Introduction.html) example. Let's say we would like to be able to access iOS calendar from JavaScript. +This guide will use [iOS Calendar API](https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/EventKitProgGuide/Introduction/Introduction.html) example. Let's say we would like to be able to access the iOS calendar from JavaScript. Native module is just an Objectve-C class that implements `RCTBridgeModule` protocol. If you are wondering, RCT is a shorthand for ReaCT. @@ -52,7 +52,7 @@ CalendarManager.addEventWithName('Birthday Party', '4 Privet Drive, Surrey'); Notice that the exported method name was generated from first part of Objective-C selector. Sometimes it results in a non-idiomatic JavaScript name (like the one in our example). You can change the name by supplying an optional argument to `RCT_EXPORT`, e.g. `RCT_EXPORT(addEvent)`. -The return type of the method should always be `void`. React Native bridge is asynchronous, so the only way to pass result to JavaScript is by using callbacks or emitting events (see below). +The return type of the method should always be `void`. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below). ## Argument types @@ -109,7 +109,7 @@ CalendarManager.addEvent('Birthday Party', { > > This section is even more experimental than others, we don't have a set of best practices around callbacks yet. -Native module also supports a special kind of argument - callback. In most cases it is used to provide function call result to JavaScript. +Native module also supports a special kind of argument- a callback. In most cases it is used to provide the function call result to JavaScript. ```objective-c - (void)findEvents:(RCTResponseSenderBlock)callback @@ -120,7 +120,7 @@ Native module also supports a special kind of argument - callback. In most cases } ``` -`RCTResponseSenderBlock` accepts only one argument - array of arguments to pass to JavaScript callback. In this case we use node's convention to set first argument to error and the rest - to the result of the function. +`RCTResponseSenderBlock` accepts only one argument - an array of arguments to pass to the JavaScript callback. In this case we use node's convention to set first argument to error and the rest - to the result of the function. ```javascript CalendarManager.findEvents((error, events) => { @@ -132,7 +132,7 @@ CalendarManager.findEvents((error, events) => { }) ``` -Native module is supposed to invoke callback only once. It can, however, store the callback as an ivar and invoke it later. This pattern is often used to wrap iOS APIs that require delegate. See [`RCTAlertManager`](https://github.com/facebook/react-native/blob/master/React/Modules/RCTAlertManager.m). +Native module is supposed to invoke its callback only once. It can, however, store the callback as an ivar and invoke it later. This pattern is often used to wrap iOS APIs that require delegate. See [`RCTAlertManager`](https://github.com/facebook/react-native/blob/master/React/Modules/RCTAlertManager.m). If you want to pass error-like object to JavaScript, use `RCTMakeError` from [`RCTUtils.h`](https://github.com/facebook/react-native/blob/master/React/Base/RCTUtils.h). diff --git a/docs/Network.md b/docs/Network.md index da7c7a6d402e69..5b26f51f9be7ad 100644 --- a/docs/Network.md +++ b/docs/Network.md @@ -7,7 +7,7 @@ permalink: docs/network.html next: timers --- -One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example. +One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example. ## XMLHttpRequest diff --git a/docs/Testing.md b/docs/Testing.md index 5cb986fcfa3a38..5fbc88693ab257 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -15,7 +15,7 @@ The React Native repo has several tests you can run to verify you haven't caused [Jest](http://facebook.github.io/jest/) tests are JS-only tests run on the command line with node. The tests themselves live in the `__tests__` directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with `npm test` from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See [`getImageSource-test.js`](https://github.com/facebook/react-native/blob/master/Examples/Movies/__tests__/getImageSource-test.js) for a basic example. -## Integration Tests. +## 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 `XCTestCase`s in Xcode (`runTest:module` is the simplest method). `RCTTestModule` is exported to JS via `NativeModules` as `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 an 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 [`IntegrationTestHarnessTest.js`](https://github.com/facebook/react-native/blob/master/IntegrationTests/IntegrationTestHarnessTest.js) and [`IntegrationTestsTests.m`](https://github.com/facebook/react-native/blob/master/IntegrationTests/IntegrationTestsTests/IntegrationTestsTests.m) for example usage.