Welcome to the TurboModule Calculator project! This project is a React Native module, written in TypeScript, designed to perform native calculations on Android and return the results to the React Native frontend. The goal of this module is to leverage the performance benefits of TurboModules in React Native to handle computations natively.
- Simples Native calculations on Android
- Fast and efficient communication between native code and React Native
- Types using typescript
Since the module is not available on npm, you need to add it directly from the repository.
-
Clone the repository:
git clone https://github.com/yourusername/turbo-module-calculator.git cd turbo-module-calculator
-
Install dependencies:
npm install
or
yarn install
-
Build the library:
cd android
./gradlew generateCodegenArtifactsFromSchema
-
Add the module to your project: In your React Native project, add the path to the cloned repository in your
package.json
:"dependencies": { "turbo-module-calculator": "file:../path-to-your-cloned-repo" }
-
Build the project: For Android:
npx react-native run-android
To use the TurboModule Calculator in your React Native project, you can follow the example below:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import {Button, SafeAreaView, useColorScheme} from 'react-native';
import RTNCalculator from 'turbo-module-calculator/js/NativeCalculator';
import {Colors} from 'react-native/Libraries/NewAppScreen';
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const onNativeSum = async () => {
const value = await RTNCalculator?.sub(1, 6);
console.log(value);
};
return (
<SafeAreaView style={backgroundStyle}>
<Button onPress={onNativeSum} title="PUSH TO SUM" />
</SafeAreaView>
);
}
export default App;
For any inquiries or further information, you can reach out to:
- LinkedIn: Ednilson Cardoso dos Santos
- Email: Ednilsonsantos43@gmail.com