Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give more details about js require. #4318

Merged
merged 2 commits into from
Dec 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions docs/NativeModulesAndroid.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,7 @@ mReactInstanceManager = ReactInstanceManager.builder()
To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of `NativeModules` each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.

```js
/**
* @providesModule ToastAndroid
*/

'use strict';

/**
* This exposes the native ToastAndroid module as a JS module. This has a function 'show'
* which takes the following parameters:
Expand All @@ -142,14 +137,12 @@ var { NativeModules } = require('react-native');
module.exports = NativeModules.ToastAndroid;
```

Now, from your JavaScript file you can call the method like this:
Now, from your other JavaScript file you can call the method like this:

```js
var ToastAndroid = require('ToastAndroid')
ToastAndroid.show('Awesome', ToastAndroid.SHORT);
var ToastAndroid = require('./ToastAndroid');

// Note: We require ToastAndroid without any relative filepath because
// of the @providesModule directive. Using @providesModule is optional.
ToastAndroid.show('Awesome', ToastAndroid.SHORT);
```

## Beyond Toasts
Expand Down