Exercise 01 : React Basics
Purpose and learning process
In this exercise you will learn the basics of the React development:
- using and rendering build-in components
- understand state and props
- event handling
- using styles
Note
It is good to test your React skills before you are starting real React Native exercises. Remember browse/learn React and React Native materials before you are doing these small practice exercises.
Repository
Remember that you will need to use mobile-exercises repository and save your work inside it. If you haven't cloned mobile-exercises repository to your local computer, then read and follow Exercises Info material first!
How to work
- Move Exercise 1 issue to Doing in your repository Issues Board
- Create ReactBasics folder to your mobile-exercises repository (in local computer)
- Create all of these small exercises with Snack Expo with React Native syntax
- Save screenshot, where is your code and app view visible, to your ReactBasics folder
- Learn React Basics from here React Native - Getting Started
Practice 1 - States and event handling
Create an application where user can increase/decrease value by pressing a Button
components (change some other button colors to your solution). Value is visible in Text
component.
Help - first try to code it by yourself
Create state for click count and modify it from functions, which will be called from button event handling.
More help - first try to code it by yourself
Import needed libraries:
1 2 3 4 5 6 |
|
Modify default application with your own UI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Define your own styles
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Example:
Practice 2 - Event handling and component rendering
Create an application where a new random number will be shown inside a ScrollView
, when a Button
component is clicked.
Help - try to first code it by yourself
Create a state array and store a random numbers inside it. Use a map
function inside a render
to iterate all the random numbers and return for example a View
components, which holds a number value. Render this returned View
component items inside a ScrollView
. Find a more information here: React - Lists and Keys
More help - first try to code it by yourself
Import needed libraries:
1 2 3 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
1 2 3 4 5 6 7 8 9 |
|
Example:
Practice 3 - Component and props
Create own Movie
component, which displays movie title, theatre and starting time. Use your own Movie
component and display a few movie information.
Example:
All done - Push practices to GitLab
After you have finished all of these small practice test, you need to push your work to evaluation.
Note
Remember include your code screen shots to your repository.
1 2 3 |
|
Go to your mobile-exercises folder and give below commands
1 2 3 |
|
Now your work is saved to local repository and pushed also to our GitLab/LabraNet. Go to your repository with Browser and check that your work is visible in there. Move your Exercise1 ticket from Doing to In Review and remember write a few lines comment to issues comment (what you have learned with this exercise). Remember do this in each exercises.