mirror of
https://github.com/status-im/react-native.git
synced 2025-02-06 14:43:49 +00:00
Fix website docs as well
This commit is contained in:
parent
127649962d
commit
b0d2c3bb26
8
website/src/react-native/index.js
vendored
8
website/src/react-native/index.js
vendored
@ -159,7 +159,7 @@ var GeoInfo = React.createClass({
|
|||||||
|
|
||||||
<h2>Extensibility</h2>
|
<h2>Extensibility</h2>
|
||||||
<p>
|
<p>
|
||||||
It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you{"'"}ve already built, and can import and use your favorite native libraries. To create a simple module in iOS, create a new class that implements the RCTBridgeModule protocol, and add RCT_EXPORT to the function you want to make available in JavaScript.
|
It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you{"'"}ve already built, and can import and use your favorite native libraries. To create a simple module in iOS, create a new class that implements the RCTBridgeModule protocol, and wrap the function that you want to make available to JavaScript in RCT_EXPORT_METHOD. Additionally, the class itself must be explicitly exported with RCT_EXPORT_MODULE();.
|
||||||
</p>
|
</p>
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// Objective-C
|
{`// Objective-C
|
||||||
@ -171,9 +171,11 @@ var GeoInfo = React.createClass({
|
|||||||
|
|
||||||
@implementation MyCustomModule
|
@implementation MyCustomModule
|
||||||
|
|
||||||
- (void)processString:(NSString *)input callback:(RCTResponseSenderBlock)callback
|
RCT_EXPORT_MODULE();
|
||||||
|
|
||||||
|
// Available as NativeModules.MyCustomModule.processString
|
||||||
|
RCT_EXPORT_METHOD(processString:(NSString *)input callback:(RCTResponseSenderBlock)callback)
|
||||||
{
|
{
|
||||||
RCT_EXPORT(); // available as NativeModules.MyCustomModule.processString
|
|
||||||
callback(@[[input stringByReplacingOccurrencesOfString:@"Goodbye" withString:@"Hello"];]]);
|
callback(@[[input stringByReplacingOccurrencesOfString:@"Goodbye" withString:@"Hello"];]]);
|
||||||
}
|
}
|
||||||
@end`}
|
@end`}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user