React Native Calculate Square Cube and Square Root Cube Root

This tutorial is very important for react native beginners who wish to create calculator application. Because in this tutorial we would going to create a react native application which would find Calculate Square Cube and Square Root Cube Root of a given number inside TextInput on button click and show the result using Alert dialog.

Contents in this project Calculate Square Cube and Square Root Cube Root using React Native App :

1. Import StyleSheet, Alert, TextInput, View and Button component in your project.

2. Create constructor() in your class and inside it we would create a State named as Holder. This state is used to store the TextInput entered value.

3. Create a function named as FindSquare(). This function is used to find and show Square of any entered value using Math.pow(Value_1, Value_2) function. This function would automatically return the Value_1 the number Power of Value_2(Value_1 * Value_1)

4. Create a function named as FindCube(). This function would calculate the Cube of given number using Math.pow(Value_1, Value_2) function (Value_1 * Value_1 * Value_1).

5. Create a function named as FindSquareRoot(). This function would calculate Square Root of given value using Math.sqrt(Value) function.

6. Create a function named as FindCubeRoot(). This function would show us the Cube Root of given value using Math.cbrt(Value).

7. Create a Root View in render’s return block . This View is used to show TextInput component and All 4 buttons. Now we would Add A TextInput and 4 Button component in this view. We would call each function on each button onPress event.

8. Create Style Classes .

9. Complete source code for App.js File :

Screenshot in android device :

Square Root Cube Root

Screenshot in iOS device :

Leave a Reply

Your email address will not be published.