Give more details about js require.

Native developers may get confused by require statement.
This commit is contained in:
sunnylqm 2015-11-24 17:30:36 +08:00
parent 64675dc078
commit e919567323
1 changed files with 4 additions and 2 deletions

View File

@ -142,10 +142,12 @@ var { NativeModules } = require('react-native');
module.exports = NativeModules.ToastAndroid;
```
Now, from your JavaScript file you can call the method like this:
Save the above code into a file named "ToastAndroid.js". Now, from your other JavaScript file you can call the method like this:
```js
var ToastAndroid = require('ToastAndroid')
// Suppose this js file is under the same directory as ToastAndroid.js.
// Otherwise change the require path.
var ToastAndroid = require('./ToastAndroid');
ToastAndroid.show('Awesome', ToastAndroid.SHORT);
// Note: We require ToastAndroid without any relative filepath because