Skip to content

Commit 4c3603b

Browse files
authored
Update pillars-turbomodule.md (facebook#3355)
1 parent 4b1aeff commit 4c3603b

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

docs/the-new-architecture/pillars-turbomodule.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ android
224224
└── java
225225
└── com
226226
└── rtncalculator
227-
└── RTNCalculatorPackage.java
227+
└── CalculatorPackage.java
228228
```
229229
230230
#### The `build.gradle` file
@@ -272,7 +272,7 @@ Second, create an `android/src/main` folder. Inside that folder, create a `Andro
272272
273273
```xml title="AndroidManifest.xml"
274274
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
275-
package="com.RTNCalculator">
275+
package="com.rtncalculator">
276276
</manifest>
277277
```
278278
@@ -282,9 +282,9 @@ This is a small manifest file that defines the package for your module.
282282
283283
Finally, you need a class that extends the `TurboReactPackage` interface. To run the **Codegen** process, you don't have to completely implement the package class: an empty implementation is enough for the app to pick up the module as a proper React Native dependency and to try and generate the scaffolding code.
284284
285-
Create an `android/src/main/java/com/rtncalculator` folder and, inside that folder, create a `RTNCalculatorPackage.java` file.
285+
Create an `android/src/main/java/com/rtncalculator` folder and, inside that folder, create a `CalculatorPackage.java` file.
286286
287-
```java title="RTNCalculatorPackage.java"
287+
```java title="CalculatorPackage.java"
288288
package com.RTNCalculator;
289289

290290
import androidx.annotation.Nullable;
@@ -504,8 +504,8 @@ codegen
504504
505505
The native code for the Android side of a Turbo Native Module requires:
506506
507-
1. to create a `RTNCalculatorModule.java` that implements the module.
508-
2. to update the `RTNCalculatorPackage.java` created in the previous step.
507+
1. to create a `CalculatorModule.java` that implements the module.
508+
2. to update the `CalculatorPackage.java` created in the previous step.
509509
510510
The final structure within the Android library should look like this:
511511
@@ -536,6 +536,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
536536
import com.facebook.react.bridge.ReactMethod;
537537
import java.util.Map;
538538
import java.util.HashMap;
539+
import com.calculator.NativeCalculatorSpec;
539540

540541
public class CalculatorModule extends NativeCalculatorSpec {
541542

@@ -614,6 +615,34 @@ public class CalculatorPackage extends TurboReactPackage {
614615
615616
This is the last piece of Native Code for Android. It defines the `TurboReactPackage` object that will be used by the app to load the module.
616617
618+
### Final structure
619+
620+
The final structure should look like this:
621+
622+
```sh
623+
TurboModulesGuide
624+
├── MyApp
625+
└── RTNCalculator
626+
├── android
627+
│ ├── build.gradle
628+
│ └── src
629+
│ └── main
630+
│ ├── AndroidManifest.xml
631+
│ └── java
632+
│ └── com
633+
│ └── rtncalculator
634+
│ ├── CalculatorPackage.java
635+
│ └── CalculatorModule.java
636+
├── generated
637+
├── ios
638+
│ ├── RTNCalculator.h
639+
│ └── RTNCalculator.mm
640+
├── js
641+
│ └── NativeCalculator.js
642+
├── package.json
643+
└── rtn-calculator.podspec
644+
```
645+
617646
## 5. Adding the Turbo Native Module to your App
618647
619648
Now you can install and use the Turbo Native Module in your app.

0 commit comments

Comments
 (0)