Make a simple math learning app with React Native

Tram Ho

Hi guys, perhaps the fastest way to learn something new, is nothing more than starting to do it right away. For react native too, after 1-2 days spent reading its docs, I created a simple app to help elementary school kids learn math in a less boring way. The app is still quite sketchy, but using it to access React native isn’t too bad. So today I will write a tutorial to help you create your first app

1) Setting

First, to start with React native, you must install it, follow the instructions of the following link is ok: https://reactnative.dev/docs/environment-setup, with test device, I choose the simulator so must install Android Studio (or you can use Genymotion -> not recommended), if you choose the real machine, the test will be much more intuitive (this way is recommended)

Install command npx react-native init <Tên app của bạn>, simple is not it. Now it starts, let’s get here

2) Create an interface

My App will have only 1 screen only, so the interface will also be extremely simple

As you can observe, I divide the layout into 3 parts: Header, Body and Footer, so my code will be arranged like this.

With each Component, I will code separately, so that later if I want to develop more, it is also more comfortable

If you’ve read this (and have done React), then recognize it and say: “Oh, it’s like Reactjs, it’s not that different”. That’s right, it’s not that different from React in terms of syntax and Component usage. However, it still has its characteristics.

Example: Card View in RN will be seen as div tag in React, tag Text is the p tag (it generally contains letters), Tag TouchableHighlight like div tag combined with button (ie clickable and style it).

In RN there is no className or class, but instead we have styles to customize the look of the app. Compared to React, the style of RN used is quite similar to styled-components in React. However, there is still more or less obvious difference, you can feel directly through the code below

Ingredients like StyleSheetView good Text We will import directly from the RN

It’s simple to do the interface right.

3) Function

In this app, I will use React Hook for the convenience, I will declare the score, the algorithm to randomize the calculation and the results.

The algorithm and ideas are quite easy to understand and simple, right. Just reassemble and we have a complete app to dabble on.

4) Demo When entering the app it will look like this

Click “Start” to get started

If you answer correctly, your score will go up

One sentence incorrect, the score will return to 0 and the message will appear

App is just that, but it’s enough for my nephew to learn math all afternoon (yaoming)

Thank you for watching my post. If there is something wrong and you would like to add additional comments, please leave a comment below to let me know, thank you: 3

Share the news now