background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Let's build WORDLE with React Native (tutorial for beginners) 🔴"

input logo icon
"videoThumbnail Let's build WORDLE with React Native (tutorial for beginners) 🔴
Table of contents
|

Table of contents

0:00
Intro
4:00
Getting started
17:30
Importing keyboard component
20:00
Building the Game Board component
45:50
Implementing Wordle game logic
1:13:04
Color coding the board and keyboard
1:36:05
Handling game won or lost state
1:50:05
Sharing game result
2:11:04
Managing daily word selection
2:16:50
App improvements
Video tags
|

Video tags

vadim savin
not just development
notjust.dev
react-native tutorial
react native ui design
react expo
react native live coding
live coding
react native aws amplify auth
react native auth
javascript
react tutorial
react native
react native tutorial
programming
learn react native
react native ui
wordle react
wordle react nativce
how to build a wordle app
code a wordle clone
wordle clone
wordle javascript
how to build a game in react native
wordle
notjustdev
reactnative
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:01
all right hello everyone what's up no
00:00:04
jazz developers
00:00:06
super pumped up uh to be back to the
00:00:09
live stream today we are building
00:00:11
something new today we are building a
00:00:13
new game in react native um yeah let's
00:00:17
first of all see what uh today's
00:00:20
tutorial is going to be about and then
00:00:22
we can have a little bit of talk
00:00:24
so uh here we have today we're gonna
00:00:27
build a wordle clone
00:00:30
most probably already know about wardle
00:00:33
from social media from especially from
00:00:35
twitter
00:00:36
and um
00:00:38
you're gonna
00:00:39
get the point in a couple of uh minutes
00:00:42
uh but yeah like everyone on twitter is
00:00:44
sharing these
00:00:45
green squares uh that was very
00:00:48
mysterious for me i was thinking like
00:00:50
what the hell
00:00:51
is happening here it's most definitely
00:00:53
another nft
00:00:55
but apparently some of the subscribers
00:00:58
told me about this world game i tried it
00:01:01
out and it's so simple and it's so fun
00:01:04
but i decided to build a tutorial to
00:01:06
show you how you can build a world
00:01:09
application with react native for ios
00:01:12
and android and by the end of this
00:01:15
video you're going to build this
00:01:17
application that you see right here
00:01:20
and
00:01:21
the point of this game is to try to
00:01:24
guess award and the world is uh unique
00:01:28
one per day for all the participants so
00:01:31
anyone who is joining the game they will
00:01:33
all try to guess the same word and i
00:01:36
think this
00:01:37
led to the popularity uh of this game on
00:01:40
twitter
00:01:41
and it's simple like you
00:01:43
start with the first row like we
00:01:45
understand that the word is from five
00:01:47
characters and yeah let's see like i
00:01:49
don't know let's put some random
00:01:51
characters
00:01:52
here and i'll put enter and if all of
00:01:56
them are green that means that we didn't
00:01:58
guess any letters
00:02:00
all right let's try another
00:02:03
another try
00:02:04
and here we see two letters with yellow
00:02:07
which means that these letters are in
00:02:10
the word but they are at a different
00:02:12
position
00:02:13
all right so i don't know let's try h3
00:02:16
the first one
00:02:18
let's enter oh we know that h is in the
00:02:21
right position because it's with green
00:02:24
always in the right position and also we
00:02:26
have an e
00:02:27
i think the word is hello and yeah
00:02:31
we won and after that you can also share
00:02:34
your result similar to the world game
00:02:38
and after you press share
00:02:40
you will copy the result that you have
00:02:43
and after that you will be able to paste
00:02:44
them here for example
00:02:46
and here you see
00:02:48
how many tries did you did you have
00:02:51
until you nailed the world
00:02:54
so um yeah this is the idea of today's
00:02:58
tutorial
00:03:00
and um yeah we're gonna build everything
00:03:02
from scratch
00:03:06
yeah super excited about that
00:03:09
and
00:03:10
yeah without further ado let's run the
00:03:12
intro and then we can get started
00:03:16
[Music]
00:03:17
[Applause]
00:03:18
[Music]
00:03:22
all right so everyone who is joining
00:03:25
today live hello guys where are you
00:03:27
joining us from
00:03:30
uh
00:03:31
right down below yeah where
00:03:33
are you currently
00:03:35
until i managed to
00:03:36
get back on track like for me it's
00:03:39
uh
00:03:41
like getting back like i almost forgot
00:03:43
everything like what i have to do here
00:03:45
but i'm gonna get there i'm gonna get
00:03:47
there
00:03:49
let me put the comments here so i could
00:03:51
see them
00:03:54
germany india argentina korea oh my god
00:03:58
everywhere in the world uh all right how
00:04:01
did you enjoy that time with uh with
00:04:04
lucas the build with lucas by the way
00:04:06
the crypto tracker that lucas is working
00:04:09
on is not done yet and we will publish
00:04:11
more videos in that project
00:04:14
including deploying an application to
00:04:18
to app store
00:04:21
morocco india
00:04:23
pakistan hello guys awesome
00:04:27
all right so um
00:04:29
without further ado let's start by
00:04:32
initializing our project and we're going
00:04:34
to use expo to do that because expo is
00:04:37
the easiest way to get started and to
00:04:39
build
00:04:40
rack native application um
00:04:42
[Music]
00:04:45
with especially if you are a beginner
00:04:47
uh expo is not sponsoring this video so
00:04:49
this is totally my point of view all
00:04:52
right so i'm going to open a
00:04:54
terminal to get started
00:05:00
and here in the terminal make sure let
00:05:03
me zoom in a bit
00:05:08
make sure you have
00:05:10
um one of a recent version of expo and
00:05:14
after that we can
00:05:15
first of all let me go into a folder
00:05:18
that i need youtube here
00:05:23
and we can uh do expo you need to
00:05:25
initialize our project and to give a
00:05:27
name for our project i'm gonna call it
00:05:30
wordle
00:05:34
lucas is amazing yeah i'm also happy
00:05:36
with uh the tutorials that he was doing
00:05:39
and i wish that he's gonna stay with us
00:05:42
for for longer to teach us
00:05:45
everything he knows
00:05:47
uh when we are asked to choose a
00:05:49
template here let's choose a blank
00:05:51
template basically the first one so just
00:05:54
press enter
00:05:56
and this will initialize a very minimal
00:05:58
application and very clean without a lot
00:06:01
of dependencies um because we will take
00:06:04
it from there and we will build
00:06:06
everything ourself
00:06:10
hello from morocco i have always wanted
00:06:12
to build that game awesome today is your
00:06:15
chance to build it uh from scratch all
00:06:18
the way till the end
00:06:22
i was trying vox implant in expo project
00:06:25
but was getting client module error
00:06:28
most probably vox implant does not
00:06:31
support expo
00:06:33
or you will have to do some extra steps
00:06:36
like i cannot answer your question um
00:06:39
from the top of my head
00:06:41
but most probably it doesn't
00:06:44
so all right our application has been
00:06:46
initialized now what we have to do is to
00:06:50
go inside the project cdwordle and here
00:06:53
we can write code and then dot to open
00:06:56
the current directory
00:06:58
using visual studio code
00:07:00
if you don't have this um alias
00:07:04
then you can simply open visuals to the
00:07:06
code and from there do open project
00:07:09
navigate to them folder that it was
00:07:11
generated and open that way
00:07:14
so now our project is open here
00:07:19
all right and
00:07:21
before we get into the code let's open a
00:07:24
terminal by going in the top right top
00:07:27
corner here terminal new terminal
00:07:30
and here we will write npm start
00:07:38
all right i have another server running
00:07:41
so i'm gonna have to stop it first and
00:07:44
then run npm start
00:07:47
all right this
00:07:49
open our export development window
00:07:53
in a browser and again let me
00:07:57
zoom in and from here what we can do is
00:08:00
to run it on either an android device or
00:08:02
ios simulator the application will work
00:08:04
on both on both android and ios
00:08:08
in my case i'm using a mac os so i'm
00:08:10
going to run it on ios simulator because
00:08:12
it runs
00:08:14
smoother
00:08:15
if you're working on windows machine or
00:08:17
linux then go ahead and run it on an
00:08:19
android emulator at the end i'm also
00:08:21
gonna test everything on an android
00:08:24
device to make sure that everything is
00:08:25
compatible
00:08:34
in your earlier tutorials you were
00:08:36
always doing typescript yeah it depends
00:08:38
from project pro to project like this
00:08:41
project is quite simple uh it's fun to
00:08:45
build but it's not very complicated and
00:08:48
for this specific project i decided not
00:08:50
to go uh with a typescript route in
00:08:53
order not to confuse
00:08:55
some beginners
00:08:57
if your project is a little bit bigger
00:08:59
than
00:09:01
it definitely worth
00:09:03
starting from the get-go with typescript
00:09:05
and having
00:09:07
everything typed there
00:09:09
i spoke about the benefits of typescript
00:09:12
and
00:09:13
let me try again to run an ios simulator
00:09:19
expo does support vox implant as far as
00:09:21
i know
00:09:23
that's a good point
00:09:26
maybe you have to
00:09:28
do the settings
00:09:30
i'll have to i'll have to
00:09:32
to look into this and i'm going to come
00:09:34
with a response
00:09:38
does it contain authentication no it
00:09:40
doesn't
00:09:42
not in this tutorial not in this episode
00:09:45
i mean because i don't think we need
00:09:48
authentication the world game like is
00:09:51
free to play like anyone can go there
00:09:53
and play
00:09:54
and i think that's
00:09:56
best for the user experience because
00:09:58
it's a simple game like you just want to
00:10:01
play i don't think we need to
00:10:03
to make the user authenticate so here we
00:10:06
have here we have our application on the
00:10:08
right uh the only thing that we see is
00:10:10
open up the js to start working on your
00:10:12
application everything is working if
00:10:14
you're new to
00:10:16
react native development or expo
00:10:18
development
00:10:20
a few words about this development tool
00:10:23
is
00:10:24
uh
00:10:25
on the right on the left side here you
00:10:27
will see your device if you click there
00:10:30
here you will
00:10:32
start seeing all the logs that are
00:10:35
coming from your application running on
00:10:37
this device this is important because if
00:10:39
something is not working come back here
00:10:41
and you'll find more details
00:10:43
about the issue or about any problem
00:10:46
that you encounter in the application
00:10:50
that was
00:10:51
this is the most important that you need
00:10:53
to know at the moment so let's go back
00:10:56
to our project and what do we have to do
00:10:59
let's open up.js
00:11:01
and here if we will update this text to
00:11:05
hello world
00:11:06
we will right away see it updated in our
00:11:10
emulator here on the
00:11:12
right perfect
00:11:15
uh so guys before we
00:11:18
start coding let's import a couple a
00:11:21
couple of files uh that will be
00:11:24
important for our project i prepared
00:11:26
them for you in order for you not to
00:11:28
waste time for example i prepared the
00:11:31
keyboard
00:11:32
component
00:11:34
and other important files there that we
00:11:36
will need such as colors you can get it
00:11:39
by following the link in the description
00:11:41
below or go to
00:11:43
assets.notjust.dev slash wordle wordle
00:11:47
yeah probably
00:11:49
you'll find the link in the description
00:11:50
below download the
00:11:53
the asset bundle and when you open it
00:11:55
you will see here
00:11:57
a source folder and some screenshot of
00:12:00
application
00:12:01
for you to easier
00:12:03
know what we are building so what are we
00:12:06
going to do with this source we are
00:12:07
going to take it and drag and drop in
00:12:10
the root of our project
00:12:13
okay
00:12:16
yes add folder to workspace
00:12:19
do you trust yes
00:12:23
no i think i did it wrong it shouldn't
00:12:26
be there
00:12:29
i messed up
00:12:33
let me try to delete it from here
00:12:37
folder
00:12:40
what did it create all right so again
00:12:44
let me
00:12:47
try to
00:12:48
copy it inside the wordle so copy folder
00:12:52
simply like that yeah copy folder
00:12:56
and now inside our project in the wordle
00:13:00
package here we see the source the
00:13:03
source contains some constants and in
00:13:05
the constants we will see i think it's
00:13:07
too much
00:13:09
in the constants for example we will see
00:13:10
the colors that we will be working with
00:13:14
uh we will see all the keys that we need
00:13:16
for the keyboard and the important thing
00:13:19
is here in the components we have the
00:13:21
keyboard component
00:13:23
that we will import soon in our app.js
00:13:27
all right uh back to our app.js
00:13:30
gs
00:13:31
let's import colors import
00:13:35
colors
00:13:37
from
00:13:39
source van
00:13:41
constant
00:13:44
constants like this
00:13:46
save
00:13:47
now for the background color of our
00:13:50
application i want to say that it's
00:13:52
colors dot black
00:13:55
all right
00:13:56
and
00:13:57
this text
00:13:59
i'm gonna delete and i'm going to add a
00:14:01
new text below
00:14:03
but before that look because our status
00:14:06
bar has a style of auto
00:14:09
i do not see the
00:14:11
clock and the wi-fi indicator and so on
00:14:14
so let's set the status bar to light in
00:14:18
order to see these uh properties here
00:14:21
okay after that what i want to do is i
00:14:24
will start with uh the title of this
00:14:26
page
00:14:27
which is wordle
00:14:30
and i'm gonna give it style equal styles
00:14:33
dot title
00:14:36
let's grab this title here
00:14:39
and start
00:14:42
first of all i'm going to set the color
00:14:44
to colors dot
00:14:46
uh light gray in order to see it on the
00:14:49
screen yes it's there
00:14:52
then
00:14:53
look i'm gonna uh
00:14:55
yeah
00:14:56
title font
00:14:58
size 32 probably
00:15:01
that's good
00:15:03
and also font weight bold to make it
00:15:06
bolder yes
00:15:09
uh the only thing that i would change
00:15:11
here for this text is the spacing
00:15:14
between letters now they're too close
00:15:16
together
00:15:18
we can do that by doing letter spacing
00:15:22
and i'm gonna give if we give 10 that's
00:15:24
too much probably seven yes that's
00:15:28
better
00:15:29
okay but the title our title
00:15:33
should be on the top of the screen let
00:15:35
me also open a screenshot so you could
00:15:37
see better what's going on there
00:15:42
here we have a screenshot
00:15:44
so as you can see the title should be up
00:15:47
top here in the application
00:15:51
our title is in the middle because
00:15:53
the container
00:15:55
of our whole application aligns
00:15:57
everything invest center so if i remove
00:16:00
this one
00:16:02
our title is not in the middle it's it
00:16:05
moved to the top
00:16:07
but i see a small issue like on some
00:16:10
devices that do not have a notch
00:16:12
everything is going to be perfect but on
00:16:14
this specific device because it has a
00:16:16
notch our text is behind the notch
00:16:19
to fix that like you could go
00:16:22
some easy route and add some margin top
00:16:25
to this container just to move
00:16:26
everything
00:16:27
below
00:16:29
but a better approach would be to use
00:16:32
safe area view
00:16:34
a component that we can import from
00:16:35
react native and i'm going to replace
00:16:38
the root view with a safe area view by
00:16:42
doing that
00:16:44
a safer review is the same view but it
00:16:46
will make sure that everything inside
00:16:48
that view is visible on the screen so
00:16:50
basically it protects you from
00:16:53
notches it protects you from i don't
00:16:55
know camera small cameras android have
00:16:58
or uh below here there is also a small
00:17:01
portion
00:17:02
where the content could be hidden behind
00:17:05
this line on the iphone
00:17:09
so save a review title everything is
00:17:11
good so far
00:17:13
i think so
00:17:15
let's go
00:17:19
okay
00:17:25
uh
00:17:26
does okay
00:17:32
so what is the next step if we look at
00:17:35
this
00:17:36
page
00:17:37
let's actually let's import our keyboard
00:17:41
and see it in action import
00:17:44
keyboard
00:17:47
keyboard
00:17:49
from
00:17:50
uh source directory then component
00:17:54
not constants component
00:17:57
then
00:17:58
keyboard
00:18:00
make sure you import
00:18:02
the keyboard from this location where
00:18:05
you have copied it and not from react
00:18:08
native because drag native also has a
00:18:10
keyboard there
00:18:12
and let's simply
00:18:15
render the keyboard
00:18:17
and here we have it at the bottom of the
00:18:19
screen we see the keyboard
00:18:21
similar to how we
00:18:23
need it
00:18:26
you can go ahead and look into the
00:18:28
keyboard and see how i build it because
00:18:30
i'm i i did it myself um in the morning
00:18:34
but
00:18:35
yeah in a couple of words what we did
00:18:37
here in the constants we have all the
00:18:40
keys
00:18:41
the key is an array of
00:18:44
three other arrays
00:18:47
every array represents one row of our
00:18:49
keyboard and has all the characters on
00:18:52
that keyboard
00:18:53
now in our component
00:18:56
we first of all map through all these
00:18:58
key rows
00:19:00
and we render one row for each row we
00:19:03
map through each key and we render a
00:19:07
pressable because we need to press on it
00:19:09
and to detect
00:19:10
presses and then we render a simple
00:19:15
the key to uppercase text to render the
00:19:18
actual letters on them on the keys
00:19:22
that's how it works you can play around
00:19:25
with styles if you want you can
00:19:28
move the sizes for example key height if
00:19:30
you want can be double the
00:19:32
size of key weave and in this case like
00:19:34
we're going to have super tall
00:19:36
keys 1.3 for me was okay
00:19:40
all right back in our app.js
00:19:44
what do we have to uh to do
00:19:50
we have to start
00:19:52
rendering the map like the whole
00:19:55
uh
00:19:56
five by i don't know one two three four
00:19:59
five six or something like that
00:20:01
uh rose
00:20:04
um
00:20:05
yeah
00:20:06
let's
00:20:07
as we can see the map here
00:20:10
i can even draw on it
00:20:13
no probably i can't
00:20:18
so
00:20:26
i cannot all right
00:20:28
don't worry so we have a map a map
00:20:31
contains
00:20:32
multiple rows as you can see six rows
00:20:36
and each individual row contains
00:20:38
one two three four five cells
00:20:41
so this is important because we are
00:20:43
going to work a lot with
00:20:46
this
00:20:47
b dimensional array in today's video
00:20:50
because everything here is actually
00:20:52
represented as a b dimensional array
00:20:56
so um for that we will start with a view
00:21:01
style
00:21:03
styles dot map
00:21:05
a view of that will contain the whole
00:21:07
map
00:21:08
after that
00:21:09
we will have a view
00:21:11
for our what is our next
00:21:14
level of component it's a row
00:21:17
it's a row and inside the row we are
00:21:19
going to have view
00:21:22
style equal
00:21:24
styles dot cell
00:21:26
so we have a map inside the map we will
00:21:28
have multiple multiple of these rows
00:21:32
and each row will contain multiple cells
00:21:36
let me
00:21:37
add these multiple cells five of them
00:21:41
okay with that being said let's start to
00:21:44
style some of it so mapro and cell
00:21:49
map
00:21:52
then we have row
00:21:55
then we have cell
00:21:59
for web map for the map
00:22:02
first of all i would like to say
00:22:05
let's
00:22:06
do a background color red to see the map
00:22:09
on the screen basically at the moment we
00:22:11
don't see it because it doesn't have any
00:22:13
width and height
00:22:15
if we do like i don't know some random
00:22:18
100 width
00:22:20
height
00:22:22
100 we will see it
00:22:24
the thing is that for the weave we want
00:22:27
the map to take the full available space
00:22:30
on the screen
00:22:32
so instead of saying width is 100
00:22:35
i will see how it should align so align
00:22:38
self
00:22:40
uh
00:22:41
stretch basically
00:22:43
stretch to fill the whole
00:22:45
space
00:22:46
in your parent component
00:22:51
we can use flat list two dimensions i'm
00:22:53
not gonna use a flat list for this use
00:22:55
case uh i'm gonna simply map and render
00:22:58
them because
00:23:00
uh we have a limited number of cells
00:23:03
like we
00:23:04
don't have like i don't know infinite
00:23:06
number of cells we know exactly how many
00:23:09
and that's why i think it's okay not to
00:23:12
use a flat list in this situation
00:23:17
uh all right so we have a line cell
00:23:20
stretch height 100 i'm gonna leave
00:23:22
height 100 uh for a moment
00:23:25
now for the row
00:23:28
what do we have let's do a background
00:23:30
color color
00:23:32
blue
00:23:33
and again we don't see anything if i add
00:23:37
um
00:23:39
again align self stretch
00:23:44
then also some
00:23:47
height
00:23:48
50 for example when we see the row with
00:23:51
a blue there
00:23:54
perfect now let's the design vessel
00:23:58
uh
00:23:59
for the
00:24:00
cell
00:24:02
i'm gonna say that
00:24:05
first of all let's do background color
00:24:09
um initially the cell will have a
00:24:11
background color
00:24:14
i know i'm gonna go with green just to
00:24:16
see it on the screen
00:24:18
and a cell could be with
00:24:21
30
00:24:24
height
00:24:25
30. everything with sizes i'm going to
00:24:27
adjust and i'm going to make sure that
00:24:28
they're responsive right now just for
00:24:30
you to see that
00:24:32
it's there
00:24:34
we see them but the thing is
00:24:37
you don't see them as a square because
00:24:39
it's multiple of them on top of each
00:24:41
other so i'm gonna add border
00:24:45
width of one
00:24:46
and border
00:24:48
color
00:24:49
of colors dot
00:24:53
gray
00:24:57
okay
00:24:58
something is there and i probably don't
00:25:00
need the background color because i will
00:25:02
still see them
00:25:04
okay the first problem that we see here
00:25:06
is that they are not in the same row to
00:25:08
fix that we will go to the row component
00:25:11
and i'm gonna say
00:25:13
flex direction
00:25:15
row
00:25:16
basically render all the child
00:25:19
components inside this row
00:25:21
in the same yeah row we see them there
00:25:25
perfect
00:25:26
now instead of saying we 30 instead of
00:25:29
hard coordinating the width of this cell
00:25:31
i will rather sell say flex 1 and this
00:25:35
will mean that
00:25:36
divide the space
00:25:40
with your siblings
00:25:42
so if
00:25:44
all the cells
00:25:46
inside that row has a flex 1 they will
00:25:48
divide the space equally if one cell has
00:25:51
flex 2 it will take to 2
00:25:54
times as much space as the others
00:25:57
so just by saying flex 1 we make sure
00:26:00
that the horizontal space
00:26:04
of these
00:26:05
cells
00:26:06
is
00:26:09
yeah spread between all the children
00:26:13
now for the height instead of saying hi
00:26:15
i would uh i want my
00:26:19
cells to be square
00:26:22
well
00:26:24
that is possible
00:26:26
using aspect ratio and if i say aspect
00:26:28
ratio of 1
00:26:30
my square become
00:26:32
my cells become square
00:26:35
if i do 1 over 2 then they will have two
00:26:38
times as much height as their width
00:26:42
that's why we need just one over one or
00:26:45
simply one
00:26:47
now uh
00:26:48
our row doesn't need the height because
00:26:50
it will take the height of the cells and
00:26:53
if i remove it you see the blue
00:26:56
moved to
00:26:57
fit our
00:26:59
cell's height
00:27:01
i don't need this blue
00:27:05
and what else i don't need
00:27:07
well uh v cell will probably have a
00:27:11
margin of five
00:27:14
is it enough
00:27:17
or even less like three is gonna be
00:27:20
enough and i'm gonna remove this red
00:27:22
thing
00:27:24
perfect i will increase the border width
00:27:27
to
00:27:28
two
00:27:29
like this
00:27:31
and let's try a dark gray yes now is
00:27:34
better or even free border with
00:27:38
yeah i think that's that's good
00:27:50
uh could you by the way show your visual
00:27:52
studio code extension in a video we have
00:27:54
a video
00:27:55
about my visuals to the code extensions
00:27:57
on the channel i can find it there or
00:28:01
momo can drop a link in the in the
00:28:04
comments
00:28:08
it's been a while yes i also missed the
00:28:12
live streams i'm i'm super busy these
00:28:15
days with with a course i've been
00:28:17
working the whole
00:28:19
like the last months
00:28:21
almost full time like every day
00:28:23
on the course and
00:28:25
finally we managed to finish the rack
00:28:28
native part we have almost everything
00:28:31
that needs to be there and now i'm
00:28:32
working on the backend part with amplify
00:28:35
we have two modules ready for um like
00:28:39
setting up everything and then
00:28:40
authentication and there like i spent
00:28:43
like
00:28:45
this week alone just
00:28:47
preparing one video from the
00:28:48
authentication like to go into
00:28:51
all the details to research and to make
00:28:53
sure that what i'm teaching you is uh
00:28:56
the industry best standard and um yeah
00:28:59
like all the edge cases that you can
00:29:01
encounter that's what you're gonna learn
00:29:03
during the course
00:29:05
so if you are not already join the wait
00:29:07
list by following the description in the
00:29:09
link in the description below and you'll
00:29:12
be the first one to be notified when the
00:29:14
course
00:29:15
is launched to the public
00:29:17
which is going to happen
00:29:19
soon in the next couple of months
00:29:23
all right
00:29:33
all right or you could just do with 100
00:29:37
with 100 percent
00:29:39
also works in some situations
00:29:42
but
00:29:43
it's a bit tricky because if apartment
00:29:45
has a padding
00:29:47
then with 100 will not work it will not
00:29:50
consider the padding of a parent
00:29:54
all right so uh we have
00:29:57
successfully rendered one row there if i
00:30:00
copy and paste
00:30:02
this row
00:30:04
again here
00:30:06
boom we have two rows
00:30:08
perfect but we are not gonna do copy
00:30:10
pasting here because
00:30:11
uh that's not the best way to do it
00:30:14
whenever you copy paste you know that uh
00:30:16
you remember about the dry concept don't
00:30:19
repeat yourself
00:30:21
and whenever you copy paste that means
00:30:23
that probably something can be done
00:30:26
better
00:30:27
so what i'm going to do i'm going to
00:30:29
leave here
00:30:31
only one cell
00:30:33
and i write away
00:30:35
see an issue
00:30:37
if
00:30:38
the cell
00:30:41
if a word will contain i don't know for
00:30:43
example three letters
00:30:45
then the cells will be too huge and it
00:30:48
will not fit all the all six rows
00:30:51
like if i do six of them they will not
00:30:53
fit for that reason i'm going to add a
00:30:56
max
00:30:58
width
00:30:59
to our cell max
00:31:01
with can be
00:31:03
i don't know 60.
00:31:05
and now our
00:31:07
cells will
00:31:09
will share this the
00:31:12
space
00:31:13
that they have but they will not have a
00:31:16
width bigger than 60.
00:31:18
i can probably do 70
00:31:21
yes that that will make sure that
00:31:22
everything is visible even on smaller
00:31:24
screen devices
00:31:26
uh but i want to make them make them in
00:31:29
the middle so for the row i'm gonna do
00:31:33
uh justify content
00:31:36
center
00:31:37
boom very in the center perfect
00:31:41
okay so
00:31:44
the amount of cells that we render in a
00:31:47
row what
00:31:49
does it depend on
00:31:51
the amount of cell that we render in a
00:31:53
row depends on how many letters does the
00:31:56
word have
00:31:57
okay so for that reason let's start with
00:32:00
defining a simple word
00:32:02
so word equal to hello all right
00:32:08
now uh that number
00:32:11
of
00:32:12
letters
00:32:15
or no let's
00:32:17
instead of doing number of letters
00:32:19
i'm gonna to split this word
00:32:24
in an array of characters
00:32:26
so um
00:32:28
letters
00:32:29
is equal to word dot
00:32:33
split and i'm gonna split based on
00:32:36
uh based on nothing and that will
00:32:40
what it will do it will return an array
00:32:42
of characters for example h the second
00:32:44
one is e
00:32:46
but then is l
00:32:48
then is l again then is o
00:32:52
now that we have this array of
00:32:55
characters
00:32:56
we can take it with letters
00:32:59
and instead i'm gonna delete all the
00:33:01
cells except for one
00:33:03
here inside this row
00:33:06
i want to
00:33:08
map through the letters
00:33:11
map
00:33:14
and for each letter what i want to do is
00:33:17
i want to render a cell here
00:33:22
save
00:33:23
boom we have five letters if i'm gonna
00:33:26
do here
00:33:27
one two three four something like that
00:33:29
we have that many uh spots as many
00:33:32
letters we have if i'm gonna do just one
00:33:35
we're gonna have only one square there
00:33:45
someone is suggesting we can wrap the
00:33:46
map in a scroll view just to handle the
00:33:48
edge cases when a number of letters are
00:33:51
a lot
00:33:52
that's a good suggestion suggestion so
00:33:56
um
00:33:57
i'm gonna first of all
00:34:00
i'm gonna get there like i'm i have an
00:34:03
idea how to showcase the problem and how
00:34:05
to show how to solve it
00:34:08
now
00:34:10
now now what do we have now
00:34:14
um [Music]
00:34:17
all right so we have
00:34:19
the
00:34:20
number of letters now
00:34:23
we need to
00:34:24
render multiple rows
00:34:27
now think about what does the number of
00:34:30
rows depend on
00:34:33
it depends on the number of tries that
00:34:35
you want to let people
00:34:40
take
00:34:41
so that
00:34:43
can be like i don't know somewhere you
00:34:45
can store it
00:34:46
number
00:34:48
of
00:34:49
tries equal to six
00:34:53
this is how many tries we want
00:35:00
one moment i'm gonna go back to the to
00:35:02
the chat shortly now i just want to
00:35:04
focus to to make sure that everyone is
00:35:07
on the same page with this uh solution
00:35:14
all right
00:35:21
um
00:35:26
well we could simply do a for loop here
00:35:30
from 0 to 6
00:35:32
and render that many rows like this is a
00:35:35
row that many rows
00:35:38
the issue with that is
00:35:43
there is no
00:35:44
not an easy way to
00:35:46
[Music]
00:35:47
loops for example six times in
00:35:50
javascript
00:35:53
and
00:35:54
for that reason we
00:35:56
will need to map but to map we need an
00:35:59
array
00:36:00
of
00:36:01
an array of data to map over
00:36:06
uh
00:36:08
look we will have to keep in state
00:36:12
all our tries basically the whole map
00:36:17
we should keep it in state the whole map
00:36:20
and what is this map
00:36:22
for example rows is equal to
00:36:26
i don't know
00:36:27
this is the first try the first try the
00:36:30
user wrote these letters
00:36:36
i'm trying to
00:36:38
show you the data structure that we're
00:36:39
gonna use the second try the user
00:36:42
wrote these words right
00:36:45
for example
00:36:48
the third row the user
00:36:50
didn't write anything yet so that's why
00:36:52
they are empty
00:36:54
and the fourth one and so on and we need
00:37:00
for example if number of tries is six we
00:37:02
need six of these arrays in our row
00:37:06
how we can generate this beta b
00:37:08
dimensional array dynamically based on
00:37:12
the number of tries
00:37:13
and based on the
00:37:15
number of letters in the world
00:37:19
uh we can do that by
00:37:23
using the array
00:37:25
dot
00:37:26
uh
00:37:27
it's
00:37:28
no it's actually new
00:37:31
array
00:37:32
here we need to specify the array length
00:37:35
the array length is the number of tries
00:37:37
because that's how many rows do we need
00:37:41
now let's fill this array
00:37:46
and we will fill
00:37:48
every
00:37:49
every row
00:37:51
with a
00:37:52
an array
00:37:54
of how many
00:37:55
how many characters
00:37:59
letters
00:38:00
dot
00:38:02
length and then we will fill that array
00:38:06
with empty strings because user didn't
00:38:10
take any chance yet
00:38:13
so our rows contains an array of rows
00:38:17
and every row contains an array of cells
00:38:21
that are empty strings at the moment
00:38:24
later on we will update them with actual
00:38:26
data that the user put there
00:38:30
okay so now our map actually depends on
00:38:35
this uh
00:38:37
on this b dimensional array that we
00:38:39
declared here this is the data that we
00:38:41
will have to render
00:38:43
on the map on the screen
00:38:48
so
00:38:49
let's take this view that renders a row
00:38:54
and instead of rendering just one row we
00:38:56
are going to map through all the rows
00:38:58
that we have so rows dot map
00:39:02
for every row
00:39:05
basically render
00:39:06
a row
00:39:08
this one
00:39:12
so for every row
00:39:14
render one row we already see it there
00:39:18
and then
00:39:19
instead of looping through these letters
00:39:22
i would rather
00:39:24
loop
00:39:25
through
00:39:27
the row itself because row
00:39:30
map and now we will have a cell
00:39:33
from the screen not a letter
00:39:37
which will contain the data about the
00:39:39
letter
00:39:40
on that like row in that specific cell
00:39:45
okay that's interesting um
00:39:50
now
00:39:52
what i want to do what i want to do
00:39:57
i want to show you how we can render the
00:40:00
data inside this row because that
00:40:02
probably will make a little bit more
00:40:04
sense so i'm going to expand this view
00:40:07
for the cell because inside the view we
00:40:10
want to render a text
00:40:12
and the text will be the
00:40:14
cell
00:40:16
and we can do two upper case
00:40:19
per
00:40:21
case
00:40:22
to make sure that the character is to
00:40:24
uppercase
00:40:25
now if i will fill all the characters
00:40:28
with an a for example
00:40:32
i see it there but we need to apply some
00:40:34
styles because it's rendered with black
00:40:36
and you cannot see it so style dot cell
00:40:40
text
00:40:43
below cell let's do
00:40:46
cell text
00:40:49
and first of all i want to change the
00:40:50
color to colors
00:40:54
light gray
00:41:01
it's styles not style okay
00:41:03
alright we see it there right away
00:41:07
we will have to adjust some styling of
00:41:08
it first of all to align it in the
00:41:10
middle
00:41:11
we are going to apply
00:41:13
justify content center
00:41:15
and align items center
00:41:18
to the
00:41:19
container to the cell
00:41:24
align not self but align
00:41:27
items
00:41:29
that's in the middle now for the cell
00:41:31
text i'm gonna do font weight
00:41:35
bold
00:41:38
and also font size
00:41:42
28
00:41:44
yes that's that's good enough let me
00:41:47
open now another screenshot from our
00:41:52
package there
00:41:55
that will contain
00:41:58
more information here so yeah the sizes
00:42:01
of the letters i think are good
00:42:10
okay so
00:42:12
how is it so far
00:42:14
is anyone following along live while you
00:42:17
are uh watching it right now
00:42:20
do you manage to do everything
00:42:23
oh uh now i will showcase the error that
00:42:26
someone was suggesting as vr
00:42:30
so for example if let's say the number
00:42:33
of tries i don't know is
00:42:34
15
00:42:36
then we'll have 15 rows
00:42:38
the issue with this is that we cannot
00:42:40
scroll and we do not see the last rows
00:42:43
so we can solve that by using a
00:42:47
scrollable or a scroll view
00:42:49
from react native
00:42:51
and we will wrap our map inside a scroll
00:42:55
view so we will replace the view for our
00:42:57
map with a scroll view
00:42:59
now our map is scrollable as you can see
00:43:03
here
00:43:05
so just by doing that we make sure that
00:43:08
on any device sizes even if it's a pager
00:43:11
i don't know like we will be able to see
00:43:13
all the lines there
00:43:16
and let me go back to six tries
00:43:20
as default
00:43:24
uh two to two
00:43:28
add some margin top is too close to the
00:43:29
title yes we can do that to the map
00:43:33
container we can add margin vertical
00:43:37
10.
00:43:41
or 20 how much do you want 20 is okay
00:43:44
yes
00:43:47
good what what's our comments we can
00:43:50
wrap the map in a scroll view just to
00:43:51
handle yes that's what we did right now
00:43:54
is the keyboard a package or a custom
00:43:56
component the keyboard is a custom
00:43:58
component that
00:43:59
you can get by downloading the set
00:44:01
bundle in the description below so here
00:44:04
is the keyboard.js that renders all of
00:44:07
our map all of our keys it's quite small
00:44:09
like 50 lines of code
00:44:11
but it it does its job
00:44:22
so how would you go about certain people
00:44:24
using different like
00:44:26
azerty
00:44:27
uh
00:44:28
instead of qwerty keyboards um i don't
00:44:31
know that's a good thing to to implement as
00:44:34
an improvement so if you want to do that
00:44:36
go ahead i encourage you to do that
00:44:40
i used a custom keyboard because we will
00:44:43
also
00:44:44
display with different colors different
00:44:47
keys depending on if we um guess them or
00:44:50
not so that's why i couldn't use the
00:44:53
default keyboard from the system because
00:44:56
we lose this quite interesting feature
00:44:58
of uh highlighting the keys that the
00:45:02
letters that you already guessed and the
00:45:04
ones that you didn't
00:45:07
uh crazy yeah looks good you can also
00:45:10
use ref for the scroll view to
00:45:12
automatically scroll when needed yes
00:45:14
that's also good that's a good
00:45:16
suggestion
00:45:17
i'm not gonna do that that's a bit extra
00:45:20
for
00:45:21
for now at least
00:45:22
but
00:45:24
yeah
00:45:25
that's what we have at the moment
00:45:29
i see never played word all makes sense
00:45:32
yes
00:45:33
all right
00:45:36
let me see what in my task list what are
00:45:39
the next steps
00:45:41
so we
00:45:42
map from the tries we render all the
00:45:45
rows
00:45:46
then we have a keyboard
00:45:49
and now probably we will have to get
00:45:51
into the uh
00:45:53
into the state
00:45:57
we will um yeah before that let's see
00:46:02
we will have to start working on our
00:46:05
game logic whenever i press on some
00:46:08
letters i want them to be filled inside
00:46:11
our map here
00:46:15
so first of all keyboard has a
00:46:18
on key pressed function
00:46:21
that we can
00:46:23
that will be called whenever we press on
00:46:25
a key and it will send us the letter
00:46:28
from that key
00:46:29
so let's implement this
00:46:31
const
00:46:34
on key pressed here
00:46:37
we will get the key
00:46:40
and it's a simple function let's do
00:46:43
console
00:46:44
worn at the moment
00:46:46
um key
00:46:49
so if i press right now on r i see r
00:46:52
here if i press on k i see k
00:46:56
perfect so
00:46:58
what should happen when we press on a
00:47:00
key
00:47:01
we should update our rows here
00:47:06
in order to update our rows and to
00:47:11
to have reactive updates so basically if
00:47:14
i simply update the row here nothing is
00:47:17
going to happen because our component
00:47:19
will not re-render
00:47:21
in order to have
00:47:22
um
00:47:24
variables that the component depends on
00:47:27
and whenever they are changed they
00:47:28
should
00:47:29
re-render the component
00:47:31
then we need to introduce state
00:47:35
state is yeah as i said we can import it
00:47:38
from use
00:47:39
state
00:47:40
from react
00:47:43
oh by the way uh the new
00:47:46
version of expo
00:47:48
uh the new version of expo where do we
00:47:50
have it package.json
00:47:53
we
00:47:56
no longer have to import react from
00:47:59
react in our components it is
00:48:01
automatically imported this is coming
00:48:03
from react native
00:48:05
but before that it you should you had to
00:48:08
always import react from react if you're
00:48:11
using the latest version of expo now you
00:48:13
don't have to do that
00:48:15
little trick but it's very useful
00:48:18
sometimes
00:48:20
so you state
00:48:23
our rows will become
00:48:26
a state so we remember it's rows then
00:48:29
set rows
00:48:31
this is the value of our state this is
00:48:34
the setter in order to update our state
00:48:38
is equal to use state
00:48:40
and here we need a default value what is
00:48:44
going to be the default value
00:48:45
well this empty array that we have
00:48:48
created here
00:48:50
so let's copy it from here paste it
00:48:55
copy it from here paste it here
00:48:58
and we will not need this rows here
00:49:03
all right now that our component is
00:49:05
using state for the rows
00:49:08
we will be able to update
00:49:11
the rows
00:49:13
and then
00:49:15
we will see these updates
00:49:17
here on our map for example if i simply
00:49:20
set rows
00:49:22
to
00:49:23
an array of just one
00:49:26
two
00:49:27
and three
00:49:30
if i press on something all the cells
00:49:32
will will be gone and only these things
00:49:35
will remain remain because that's what
00:49:38
we declared here a map with only one row
00:49:44
okay um
00:49:46
how do we
00:49:48
update uh specifically on the
00:49:53
the cell that we are interested in
00:49:56
well we have to
00:50:00
remember
00:50:02
what is the current active
00:50:05
cell
00:50:06
are we trying to write a letter on the
00:50:09
first cell or the second cell or the
00:50:10
third cell i don't know we need to keep
00:50:12
track of that
00:50:14
for that i will also use a state
00:50:16
variable const
00:50:19
named current row
00:50:22
set current
00:50:24
row use
00:50:26
state and that's gonna start from zero
00:50:30
the same for that const
00:50:33
current
00:50:34
um
00:50:36
i don't know
00:50:38
cell
00:50:39
or
00:50:42
it's the index like the the number of a
00:50:44
column or
00:50:46
current low current column let's go with
00:50:48
column
00:50:50
set current column usually uh when you
00:50:53
work with b dimensional arrays there is
00:50:55
this
00:50:57
thing as rows and columns so that's why
00:51:00
we need these two
00:51:02
you state as well zero
00:51:06
all right now
00:51:08
what we have to do is to update
00:51:11
the rows
00:51:13
at this position at current row the and
00:51:16
current column
00:51:18
to contain the new key
00:51:20
so how could we do that
00:51:22
well we could do i don't know row equal
00:51:25
um
00:51:27
where no row at current
00:51:30
row
00:51:33
then is
00:51:34
in the second part is current column
00:51:37
to get the row and the column is equal
00:51:40
to key
00:51:44
note robot rows
00:51:46
then just update them in the state set
00:51:49
rows with rows
00:51:52
that's
00:51:53
that's it
00:51:54
and nothing is happening
00:51:56
why nothing is happening is because we
00:51:58
have to
00:51:59
we cannot update state variables
00:52:02
directly
00:52:04
basically what we have to do is to
00:52:06
create a copy of this array update that
00:52:09
copy and after that set it back
00:52:12
in state
00:52:15
for that i'm going to create a simple
00:52:16
function
00:52:18
because
00:52:19
we have a b dimensional array and it's
00:52:22
not that simple to to copy like we need
00:52:24
to two steps to copy it so copy
00:52:29
array
00:52:31
equal we will get the array here
00:52:34
and we will return what we will return
00:52:37
the array
00:52:39
well to
00:52:41
copy a one dimensional array we simply
00:52:44
do
00:52:45
with the structure of the array into and
00:52:48
we destruction values of one array into
00:52:51
a brand new array and that will create
00:52:54
a new array
00:52:56
so repetitive but yeah that's uh that's
00:52:58
how you do it for
00:53:01
for one array
00:53:03
but
00:53:04
our array is b dimensional and we need
00:53:07
to
00:53:09
uh where do we have it so for example
00:53:18
how do you start that like this
00:53:21
so if you have
00:53:23
one two
00:53:25
three
00:53:26
then our syntax
00:53:29
uh cr
00:53:30
cloned this the top the top array
00:53:34
but the arrays inside they're still the
00:53:36
same so for that reason we will have to
00:53:41
map
00:53:42
through the rows
00:53:45
and
00:53:46
do the same thing basically
00:53:48
duplicate the rows by spreading them
00:53:52
if i'm not mistaken that's how you do it
00:53:57
all right
00:53:59
let's give it a go
00:54:01
so
00:54:03
const updated rows equal copy array
00:54:09
and we will take the
00:54:11
rows
00:54:12
we will
00:54:14
create a copy of an array then we will
00:54:16
update this array
00:54:18
and then we will set it back in state
00:54:22
boom
00:54:24
let's have a look
00:54:26
what is happening there
00:54:28
if i do r yes
00:54:30
we have our first letter in our map here
00:54:41
all right how's it going guys
00:54:44
what do you think about github co-pilot
00:54:47
man i wanted to try it for so long like
00:54:50
from from summer when i received an
00:54:53
invitation to try it out but i didn't
00:54:56
manage to to find time to try it out i
00:54:58
really want to do it
00:55:00
i just yeah i'm too busy to
00:55:04
to get into it
00:55:08
but i saw i saw how it works and i
00:55:10
really think that i will enjoy it it
00:55:12
will save a lot of time
00:55:13
everything that can save me time like
00:55:16
that's a good investment that's a good
00:55:19
thing
00:55:23
so we updated the rows but if i press
00:55:26
again and again i still
00:55:28
work with the same cell with that first
00:55:31
cell
00:55:34
how we can
00:55:37
move to the next cell well we need to
00:55:39
move that current uh column
00:55:42
to the next cell
00:55:45
so after we update the rows we will set
00:55:48
current column
00:55:50
to the
00:55:52
current column
00:55:54
current column plus one
00:55:58
save
00:55:59
now if i do f it's the first one then we
00:56:02
move to the second one then r when t
00:56:05
then h that's good uh i also want to
00:56:09
in order to see for us visually which is
00:56:13
the active
00:56:14
cell we can do some um
00:56:18
some interesting stuff here on the
00:56:20
styles of our cell
00:56:22
so i'm going to
00:56:24
put this inside an array because i want
00:56:27
to
00:56:28
add
00:56:29
the border
00:56:31
color
00:56:32
i want it to depend
00:56:34
if that's the cell is active
00:56:39
um
00:56:42
so
00:56:46
is
00:56:47
cell active
00:56:49
that's going to be a function but we'll
00:56:50
implement in a moment
00:56:52
uh the border color will be colors dot
00:56:58
colors dot
00:57:00
i don't know gray that's how you do it
00:57:03
otherwise oh i forgot to put it inside
00:57:06
the object that's why nothing is working
00:57:08
here
00:57:12
light gray otherwise
00:57:14
what was the
00:57:16
dark gray
00:57:19
colors dot
00:57:21
dark grey save
00:57:24
now let's um implement this cell is
00:57:27
active
00:57:28
so i'm going to implement it here const
00:57:31
cell is active we need to
00:57:34
get the row and the column to understand
00:57:37
if it's active or not and we will return
00:57:40
at
00:57:41
return true if row is the same as
00:57:46
uh current row
00:57:48
and if column is equal to current column
00:57:54
now uh how do we get the
00:57:58
index of our row and index of our column
00:58:01
because we do not have them here the row
00:58:03
is actually
00:58:05
an array of data and the cell is a
00:58:07
letter well when mapping were
00:58:10
in most of
00:58:12
javascript array methods
00:58:15
the first one the first very value that
00:58:17
you will get is the value itself the
00:58:20
second one is the index
00:58:22
so i can do here i
00:58:24
and for the cell i can do j
00:58:26
and i represents the index of our row j
00:58:30
represents index of our column
00:58:33
i can pass them here all right so right
00:58:36
away we see
00:58:38
uh
00:58:41
the active
00:58:43
the active cell
00:58:45
uh highlighted so if i do f here active
00:58:48
cell moves to the next one
00:58:50
and so on until we reach the end after
00:58:53
that i do it it moves
00:58:55
to the to the next one which we do not
00:58:58
have
00:58:59
and now i can simply add a lot of um
00:59:02
letters there
00:59:05
um
00:59:06
yeah in order not to be able to add a
00:59:08
lot of letters here we will need to add
00:59:10
some extra um
00:59:12
some extra checks
00:59:14
but look um
00:59:17
while we are still here working with
00:59:19
mapping and so on i want to point to a
00:59:24
warning that we get the warning is each
00:59:26
child in the list should have a unique
00:59:28
key prop
00:59:30
where is it coming from and where do we
00:59:33
have lists
00:59:34
well basically
00:59:36
whenever we map through an array of data
00:59:39
and render some
00:59:41
items for each
00:59:44
element in that data array
00:59:47
what we are doing here
00:59:49
then
00:59:50
you need to provide a key
00:59:53
a unique key to that
00:59:56
component
00:59:58
and that's because by mapping through
01:00:01
through an array of data you potentially
01:00:03
can have like thousands of elements
01:00:06
and react uh needs to know how to
01:00:10
properly re-render the components when
01:00:13
the data changes
01:00:15
and for that it needs a key so it's uh
01:00:18
just for
01:00:19
improving the performance behind the
01:00:21
scenes uh for react
01:00:24
uh what key can we give to this view
01:00:28
well we can um
01:00:30
this is a key and the same should happen
01:00:33
to our row view
01:00:35
it should also have a key
01:00:37
for the row it's easier so i'm gonna do
01:00:40
i'm going to add a template string with
01:00:43
backticks
01:00:45
and i'm going to say row and then
01:00:48
dash
01:00:49
and here
01:00:50
the index of our row
01:00:52
so basically the first row will have a
01:00:54
key row 1 then row 2 row 3 row 4 and so
01:00:58
on
01:00:59
for the key of our cell
01:01:03
we can do something similar cell
01:01:07
can be
01:01:09
first of all we include the
01:01:12
id of our row and then we include the id
01:01:16
of our cell
01:01:18
just to have a unique key for all the
01:01:22
cells that we have here on the map
01:01:24
all right by doing that if i refresh
01:01:27
i don't see the warning anymore because
01:01:29
both our
01:01:30
lists
01:01:32
first one
01:01:33
and the second one contain a unique key
01:01:39
perfect hello hello everyone who is
01:01:41
joining uh
01:01:44
yeah a quick status update what we are
01:01:46
building today is a world
01:01:49
game in react native and if you're not
01:01:51
familiar familiar this is a simple
01:01:55
word game where you are trying to guess
01:01:58
one word which is unique
01:02:01
uh not unique which is the same for
01:02:04
everyone during the same day so everyone
01:02:06
is trying to guess the same word
01:02:09
and
01:02:10
um yeah like you feel in the first row
01:02:13
uh if it's green that means that the
01:02:16
letter that you chose is the correct one
01:02:18
and is on the correct position if it's
01:02:20
orange the letter is in the word but not
01:02:24
on the wrong position and if it's gray
01:02:25
like you
01:02:27
didn't guess the letter so simple and
01:02:29
very fun game
01:02:31
that we are trying to build in react
01:02:33
native
01:02:46
john thank you very much for your
01:02:48
message
01:02:50
um i'll not read it because it it's in
01:02:52
russian but yeah i really really
01:02:54
appreciate your
01:02:55
your support
01:03:06
all right
01:03:10
so where are we at well uh the next
01:03:13
issue that we are trying to solve is not
01:03:15
to overflow the row when we
01:03:19
fill in all the
01:03:22
columns
01:03:24
so how do we do that
01:03:26
well we need to check if
01:03:32
um
01:03:35
so we need to do this step
01:03:38
only if
01:03:40
current column
01:03:42
is
01:03:43
less
01:03:44
than the
01:03:48
letters dot
01:03:50
length
01:03:54
or let's not depend on this letter
01:03:56
because i don't know maybe we will have
01:03:58
it or maybe we will not have it in
01:04:00
future but our map of rows we will
01:04:03
always have
01:04:04
so
01:04:05
if current column is
01:04:07
less than rows at position zero because
01:04:10
if i just do like this it will return
01:04:13
the number of rows but i want the number
01:04:16
of columns and i'm gonna take it from
01:04:18
the first row
01:04:21
uh let's try to refresh if current
01:04:23
column is less than that let's try
01:04:26
one two three four five
01:04:30
and now i cannot do any more
01:04:32
well perfect
01:04:35
first one is uh done inputting things
01:04:39
now let's see how we can clear things
01:04:43
like whenever i press on this clear
01:04:45
button
01:04:47
so
01:04:48
uh to do that
01:04:50
i'm going to import
01:04:52
the or from constants i'm going to
01:04:55
import this clear
01:04:58
label which simply
01:05:01
says clear but it's better to have them
01:05:04
as constants because you know that
01:05:06
you're not making any typos and if you
01:05:08
do like your javascript will tell you
01:05:12
so
01:05:13
let's do it like this if
01:05:15
key
01:05:16
is equal to
01:05:20
clear
01:05:24
then we need to do something
01:05:28
we need to do something and then we also
01:05:30
need to
01:05:31
return because we don't want to get here
01:05:36
what do we have to do when we clear so
01:05:39
let's visualize it if i have two
01:05:43
um two letters here the first one is at
01:05:46
position zero
01:05:48
the t is at position one and our active
01:05:51
current column is at position
01:05:53
zero one two this is two
01:05:57
so basically we need to
01:05:59
move our current column
01:06:01
one
01:06:04
cell behind and then remove
01:06:07
what is inside that cell right
01:06:10
um
01:06:12
so first of all let's remove what's in
01:06:14
the previous cell so const previous
01:06:17
column is equal current column -1
01:06:23
now
01:06:26
let's copy this from here
01:06:29
updated rows
01:06:31
not in the current column but at the
01:06:33
previous column
01:06:34
will be equal to nothing we remove what
01:06:38
was
01:06:39
in the previous column
01:06:41
then we update the rows
01:06:43
and we also need to update the current
01:06:45
column
01:06:47
to the
01:06:48
previous column
01:06:52
just to move the active
01:06:54
one back let's press on the clear and
01:06:56
see if it works boom it works
01:06:59
now it works and if i do it one more
01:07:01
time
01:07:02
we go in the negatives we lose track of
01:07:04
it um
01:07:07
to fix that let's do it like this
01:07:10
if
01:07:11
priv column
01:07:14
is more or equal than zero right
01:07:17
previous column
01:07:18
if it's more or equal than zero we need
01:07:20
to do
01:07:22
this
01:07:24
the return should still be outside of
01:07:26
this if statement because
01:07:30
none
01:07:32
even though
01:07:33
it's not like we need to stop here
01:07:35
because we don't if we press on the
01:07:37
clear we don't want to execute this one
01:07:41
so if i
01:07:42
fill in some letters and if i press
01:07:44
clear clear clear and one more time
01:07:47
clear nothing happens because we are on
01:07:49
the
01:07:51
first column here
01:07:53
and if i fill in all of the way
01:07:57
yep it still works
01:08:04
perfect
01:08:05
the clear works
01:08:08
following but at the slower pace
01:08:12
hey mr frank you're back this is such a
01:08:16
great idea of a dm world is so much fun
01:08:18
yes i also started uh playing it and i'm
01:08:21
enjoying itself i'm enjoying it and i
01:08:24
decided to to build it thank you very
01:08:26
much for the donation frank
01:08:29
i remember you are one of the first
01:08:32
supporters of the channels
01:08:34
thank you
01:08:37
okay
01:08:43
uh the next
01:08:45
key that we want to
01:08:48
uh handle is the enter key right so for
01:08:52
that i'm going to import the same
01:08:54
enter keyword from our constants
01:08:58
and the same way as we do if key is
01:09:01
clear
01:09:04
do this
01:09:05
the same way i'm going to check
01:09:08
if
01:09:09
key
01:09:10
is equal to
01:09:12
enter
01:09:14
if key is equal to enter
01:09:16
what do we have to do
01:09:19
well
01:09:21
we have to
01:09:22
move to the next row and to the first
01:09:25
column
01:09:27
easy let's check
01:09:29
set current
01:09:32
row to the row plus one
01:09:37
then set current
01:09:40
column to zero because we want to start
01:09:44
from the
01:09:45
left
01:09:47
and that's probably it and if i press
01:09:49
enter can find variable row
01:09:53
because it's current
01:09:55
row
01:09:59
enter boom we are from a new line
01:10:03
enter we are from a new line the issue
01:10:04
is that i can do enter
01:10:07
without finishing them the sentence so
01:10:10
for that reason i'm gonna have to do one
01:10:12
more extra check here
01:10:14
if
01:10:17
rows
01:10:20
advect
01:10:21
current row
01:10:23
dot
01:10:26
no no no i just need to check if
01:10:28
current row
01:10:30
no current column if a column is on the
01:10:34
last
01:10:39
cell that means that we have full
01:10:42
a full word so if current column is
01:10:45
equal
01:10:47
to the amount
01:10:51
of columns that our
01:10:53
map have
01:10:55
length
01:10:56
then we can do this
01:10:59
do you follow it
01:11:00
is it clear
01:11:02
can you write in the description if
01:11:04
something is not clear and if i have to
01:11:06
go over it again i understand it might
01:11:08
be confusing because we have we are
01:11:11
working a lot with this be the b
01:11:13
dimensional array
01:11:14
so it's
01:11:17
for for some people it might be
01:11:18
challenging i i agree
01:11:21
let's test it now uh so if i have a
01:11:23
couple of them i press enter nothing
01:11:26
happens perfect if i press clear it
01:11:28
clears however if i
01:11:31
have it full i press enter it moves from
01:11:34
a new line
01:11:35
perfect
01:11:38
that's good that's good
01:11:40
um
01:11:43
we are doing good progress
01:11:46
amazing
01:11:48
look uh what is our next steps
01:11:53
you be doing backhand or will you store
01:11:55
all of these words locally or will you
01:11:58
leave that up to us
01:12:00
uh in this
01:12:01
episode i'm not gonna do the back end
01:12:04
and uh i'm thinking that all the words
01:12:06
i'll keep them locally because there is
01:12:09
one word per day so you can easily put
01:12:13
all of them and that's not going to be a
01:12:14
lot of data that's going to be a couple
01:12:16
of uh kilobytes
01:12:18
or bytes
01:12:21
hey seems i'm late to the party no
01:12:23
you're not late like we
01:12:25
um yeah we have some progress but you
01:12:28
can always go back and watch it from the
01:12:30
beginning
01:12:34
uh what phone do you use in vs code i
01:12:37
don't remember but i made a video about
01:12:38
that specifically for forbids
01:12:43
hello
01:12:44
hello marco hello
01:12:47
sonix i don't know
01:12:57
okay
01:13:00
let's start
01:13:02
let's start
01:13:04
to add some colors to our project
01:13:08
uh you make it look easy
01:13:10
um
01:13:13
the thing is that i've prepared a bit
01:13:15
this morning for the game and that's why
01:13:19
it looks easier
01:13:21
uh don't get the wrong impression like
01:13:23
if you're struggling with this like i
01:13:26
totally understand like this is quite
01:13:28
complicated
01:13:29
um
01:13:30
and take your time try to understand
01:13:33
what you're doing
01:13:34
if you don't understand like why do we
01:13:36
have here rows at zero like if i put
01:13:39
rows at one will it still work
01:13:41
and experiment like this like
01:13:44
why do we have more or equal than zero
01:13:46
if i put just more than zero will it
01:13:48
still work and you give it a try um
01:13:52
and then you try to clear and you see
01:13:54
that you cannot uh clear the first one
01:13:56
oh that's why we need more or equal than
01:13:59
zero and so on like yeah try to
01:14:01
understand why we are doing these things
01:14:07
wouldn't the typescript based one make
01:14:09
it easier to work uh for people that
01:14:11
know typescript yes it would
01:14:14
for people that don't
01:14:17
know
01:14:19
but not not hugely like this is
01:14:21
relatively small application so
01:14:27
it's not mandatory to use typescript
01:14:32
maybe you could make use of user reducer
01:14:39
that might be interesting
01:14:41
but i'm not gonna do that i have it now
01:14:44
because i'm gonna confuse you even more
01:14:50
how to store word in icloud
01:14:53
uh in icloud i don't know maybe you
01:14:55
meant just cloud
01:14:58
we could create a cloud backend for this
01:15:01
application using amplify or firebase or
01:15:04
any other backend that we want
01:15:06
and to query that word of the day from
01:15:08
there
01:15:09
that's one approach as well
01:15:13
um
01:15:14
yes let me check if we are on track with
01:15:16
everything that we have to do
01:15:18
uh i'd let her to the map we did that
01:15:21
don't overflow the world clear enter
01:15:24
yes
01:15:25
the next step is our
01:15:28
yeah as i said adding some background
01:15:31
colors
01:15:35
how we are going to do that
01:15:40
well um
01:15:42
background colors we need to add to our
01:15:45
cell here right
01:15:48
so uh what i'm gonna do
01:15:51
is
01:15:53
i am going to
01:15:55
add a new style here to these styles as
01:15:58
background color
01:16:01
and i'm not gonna try to do all the if
01:16:03
statements here even though i can with
01:16:05
question mark operator but we have a lot
01:16:07
of them that's why i'm going to
01:16:09
implement a function get
01:16:11
cell
01:16:13
bg color
01:16:15
color and i will send to that
01:16:19
function
01:16:21
um
01:16:22
i'll send three things i'll send the
01:16:24
actual letter
01:16:26
like the cell
01:16:28
instead of calling it cell i should
01:16:30
probably call it letter because it's a
01:16:33
letter there
01:16:37
and here as well letter
01:16:40
can fire but okay
01:16:42
i'll send to this function get a cell
01:16:45
background color the cell
01:16:47
the
01:16:49
row and the column
01:16:51
i'll send everything to know about it in
01:16:52
order to understand if it's
01:16:55
uh green if it's orange or if it's
01:16:59
black
01:17:00
so this function let's implement it here
01:17:03
const
01:17:04
equal
01:17:06
letter
01:17:07
a row and column
01:17:10
so
01:17:12
let's re let me remind you
01:17:14
um what are the colors for i don't have
01:17:19
any warranties here but the thing is
01:17:22
if you guessed if a letter
01:17:26
if
01:17:27
okay let me try again if you guessed the
01:17:29
letter and the letter is in the right
01:17:32
position
01:17:33
then it is displayed with a
01:17:35
green background
01:17:37
if
01:17:38
the letter is not on the right position
01:17:41
but the letter is inside the word that
01:17:44
you are trying to guess
01:17:45
then the background will be
01:17:47
orange
01:17:49
and otherwise if the letter is
01:17:51
completely not in that word it's going
01:17:52
to be with
01:17:54
black
01:17:55
so with that uh in mind let's start by
01:17:59
checking
01:18:01
if
01:18:03
uh
01:18:04
if
01:18:06
our
01:18:08
letter
01:18:10
i think we do not need to send the
01:18:13
letter here i mean it's not mandatory
01:18:16
because we based on the row and the
01:18:17
column we can take it from our
01:18:20
rows here
01:18:22
but having it it's still
01:18:24
okay uh
01:18:26
if letter
01:18:29
that we're trying to display the
01:18:31
background is the same
01:18:33
as the
01:18:35
where do we have it
01:18:36
this
01:18:37
word that we are trying to
01:18:39
guess
01:18:41
this word is an array of letters
01:18:45
but we need to
01:18:47
get the letter add the position column
01:18:51
if they are the same
01:18:53
that means that we guessed the letter
01:18:55
and it's on the right position because
01:18:57
we are checking specifically on that
01:18:59
position
01:19:01
then we will
01:19:03
return
01:19:04
colors dot
01:19:07
think it's primary
01:19:11
all right
01:19:12
if we didn't guess the letter let's
01:19:14
check if the
01:19:16
word that we are trying to guess
01:19:18
basically letters
01:19:23
if it includes
01:19:26
our letter that we are trying we we
01:19:30
input there
01:19:32
if it includes
01:19:35
that means that the background color
01:19:37
should be colors dot
01:19:41
secondary
01:19:45
and
01:19:46
i don't know
01:19:49
otherwise it can be colors dot
01:19:54
usually what background color does we
01:19:56
sell have background color dark gray
01:20:00
what other colors do we have
01:20:02
dark gray i think we will go with the
01:20:05
black one
01:20:10
oh no that's border color dark gray
01:20:15
yes we're gonna go with dark gray
01:20:17
actually
01:20:18
so
01:20:19
if none of these are working then it's
01:20:22
dark gray
01:20:27
what's happening there
01:20:29
can find variable cell
01:20:31
get background color not cell but
01:20:34
letter
01:20:40
background color
01:20:47
what's happening
01:20:49
come on
01:20:53
okay
01:20:54
uh
01:20:55
if we didn't have this one
01:20:57
all right so as you can see if we don't
01:21:00
have anything our
01:21:02
cells are basically empty like they do
01:21:04
not have any background color they are
01:21:07
you can see behind it
01:21:09
if we add this all of them
01:21:11
become
01:21:12
uh
01:21:13
gray and if i will start writing things
01:21:16
you feel like h it's going to be orange
01:21:19
because
01:21:20
h is inside our hello world
01:21:23
and if i'm going to do
01:21:25
l here
01:21:27
that's going to be green because it's in
01:21:28
the right place
01:21:30
the thing is that we don't want to show
01:21:33
these colors to the current row we want
01:21:35
to show them to all the rows above so if
01:21:39
i'm going to do here
01:21:40
like i want the colors to the first row
01:21:43
but i don't want to see the colors here
01:21:45
because that's cheating we lose the
01:21:47
point of the game
01:21:49
um
01:21:51
let's think how to fix this issue here
01:21:53
get cell
01:21:54
background
01:21:56
basically i'm going to add another if
01:21:57
statement
01:21:59
checking if
01:22:00
the row that we are currently
01:22:06
the row for the letter that we are
01:22:08
rendering at the moment
01:22:10
if it is
01:22:12
more or equal than the current row
01:22:15
then the color will be
01:22:17
colors dot black basically the empty
01:22:21
thing oh here we have it
01:22:24
so
01:22:25
um
01:22:26
yeah the row that we are working with
01:22:28
will be
01:22:30
with
01:22:31
black background all of them doesn't
01:22:34
matter if it's the right one but the
01:22:36
wrong one we don't want to show it to
01:22:38
user so he can clear and try again and
01:22:41
only after he does enter we will display
01:22:44
the right color there and if i'm gonna
01:22:46
do hello
01:22:48
boom all green
01:22:51
perfect
01:22:53
all right
01:23:00
what are good resources to start
01:23:02
learning ui there are a lot of videos on
01:23:04
this channel that are focused on ui
01:23:07
development you can start with
01:23:10
tesla clone that's an easy clone
01:23:13
of an application specifically for
01:23:16
beginners and by implementing that you
01:23:18
will implement you will build a
01:23:22
tesla application the tesla website in a
01:23:24
react native
01:23:26
way
01:23:33
uh i'm getting an error in mongodb and i
01:23:35
can solve it there is no solution for it
01:23:36
on the internet
01:23:38
i don't believe that there is no
01:23:39
solution on the internet on the internet
01:23:42
you can find everything
01:23:44
it's a matter of uh how you search it
01:23:48
you can you can send it to
01:23:51
to me in private or on discord and i'm
01:23:52
gonna try to help you but
01:23:55
it's out of scope for this video so
01:23:57
let's try to be focused here
01:24:01
uh okay let's see our questions
01:24:06
uh someone was suggesting first you need
01:24:08
to check if it includes the letter if so
01:24:11
check if a letter is in the rights index
01:24:14
if so is green if not it's orange pretty
01:24:17
simple
01:24:18
that's one solution
01:24:20
but
01:24:21
i first check if it's in the right
01:24:23
position and if yes i return green
01:24:26
and only then only when i know that it's
01:24:30
not in the right position i check but
01:24:32
maybe it's in the word and then i return
01:24:34
secondary i think this is a bit cleaner
01:24:39
um
01:24:41
let's see is a check one current row
01:24:43
plus one not necessary
01:24:45
current row plus one
01:24:47
is the check
01:24:48
are you do you mean here current row
01:24:51
plus one
01:24:56
or where
01:25:10
can we make an application with
01:25:11
subscription model using uh react native
01:25:14
payment gateway yes we have this planned
01:25:17
for the very near future like in the
01:25:20
couple of next week we're gonna have
01:25:22
uh a tutorial on payment integrations
01:25:29
okay guys so let's get back to our
01:25:31
application so we have our colors
01:25:41
what would be the next steps what are
01:25:43
the next steps
01:25:51
look if we are working with the colors
01:25:55
at the moment let's also implement the
01:25:57
colors for our
01:25:59
keyboard
01:26:00
the way i implemented the keyboard is if
01:26:03
you send here green caps
01:26:06
an array of caps like for example a
01:26:09
and b should be green
01:26:11
and orange caps
01:26:14
or how is it
01:26:17
green
01:26:19
what our caps are there
01:26:21
uh yellow caps
01:26:24
and if i do yellow caps
01:26:27
c
01:26:28
and w
01:26:30
then they are rendered with that
01:26:32
specific color
01:26:34
so um we need to
01:26:38
uh collect
01:26:40
all the green letters from our map
01:26:43
also all the yellow um keys from our map
01:26:47
and also all the black
01:26:49
keys from our map in order to send it to
01:26:52
the keyboard to properly properly render
01:26:54
them there
01:26:56
how we're going to do that
01:26:59
well we will
01:27:01
loop
01:27:02
through
01:27:03
our map
01:27:06
this map
01:27:07
rose
01:27:09
and we will
01:27:11
take
01:27:14
yeah we will take the
01:27:17
letters
01:27:18
based on the colors right
01:27:23
for example
01:27:26
const green caps
01:27:29
is equal
01:27:30
to rows because
01:27:34
that's the data that we're working with
01:27:37
dot
01:27:38
um i don't know probably map
01:27:40
and for each row
01:27:43
we are looking into them
01:27:48
row dot
01:27:50
map and here is our cell so what are we
01:27:53
gonna do with the cell
01:27:58
we need to check
01:28:01
look using the same guest cell
01:28:02
background
01:28:04
color
01:28:07
we're going to check if the color is
01:28:10
primary
01:28:12
and only if the color is primary we're
01:28:14
gonna
01:28:15
keep that letter for our green caps
01:28:19
so
01:28:20
if
01:28:22
get
01:28:24
cell background color
01:28:26
of our letter
01:28:29
you know what i'm going to simplify this
01:28:31
uh
01:28:32
letter because we can get it
01:28:34
automatically
01:28:36
you know
01:28:37
and it will have to send less data
01:28:40
through properties because const letter
01:28:44
is equal simply rows at position row and
01:28:48
at position column that's it
01:28:54
okay here get background color
01:28:57
uh
01:28:58
cell
01:28:59
not cell but we need the index of our
01:29:02
row and the index of our column
01:29:07
i and j
01:29:09
so if get background color is equal to
01:29:13
colors dot primary
01:29:15
then we
01:29:17
need that key to remain in the caps so
01:29:20
instead of mapping i'm gonna switch to a
01:29:23
filter basically
01:29:26
we get rid of all the
01:29:28
um
01:29:30
all the letters except the ones that
01:29:33
have a
01:29:34
green background
01:29:37
and if i will do console.log
01:29:43
green caps
01:29:45
let's have a look at what we will see
01:29:47
here
01:29:49
so it's nothing if i do i don't know
01:29:54
and enter
01:29:59
then we don't have anything but if i'm
01:30:01
gonna do hell
01:30:04
something like this
01:30:06
we see that
01:30:08
there is these three letters h e and l
01:30:12
only these letters
01:30:13
but as you can see
01:30:16
we we have an array of arrays
01:30:19
but what we need to do
01:30:23
let's do it like this one more time
01:30:25
i need here to get the
01:30:27
o
01:30:28
enter
01:30:30
what i need to do is basically merge all
01:30:33
these arrays i need an array containing
01:30:35
h e l and o
01:30:39
so
01:30:40
basically we need to
01:30:42
merge all the values of this
01:30:44
arrays
01:30:46
to do that uh easy
01:30:48
the easiest solution will be instead of
01:30:51
map to call a flat map
01:30:54
and this is gonna do what i told you uh
01:30:57
just now it will
01:30:59
map through everything and advance it
01:31:01
will flatten that array basically it
01:31:04
will merge all the
01:31:07
child arrays
01:31:08
hello
01:31:11
thank you
01:31:14
yes you can
01:31:16
you're welcome
01:31:19
so
01:31:20
um
01:31:24
now let's have a look with a flat map
01:31:27
here we have it it's a simple array of
01:31:30
values
01:31:31
and if i'm going to take
01:31:33
the green caps and send them to our
01:31:36
keyboard
01:31:38
green caps
01:31:40
then they will be h e l and o
01:31:44
perfect
01:31:45
let's do the same thing for our yellow
01:31:47
caps
01:31:49
uh to do two green caps
01:31:52
look for the yellow caps i'm gonna have
01:31:54
to copy paste this thing and do it
01:31:57
again
01:31:58
but
01:32:01
you know what i'm going to declare
01:32:03
better a function
01:32:05
that will handle this situation
01:32:10
get all
01:32:12
um
01:32:14
letters
01:32:16
with color
01:32:18
and then i'm gonna send a color here
01:32:22
and i'm gonna do it like
01:32:26
this
01:32:27
return
01:32:31
rows
01:32:32
do everything
01:32:34
but check it based
01:32:37
not on the colors.primary but on this
01:32:39
color
01:32:46
and now our green caps are simply get
01:32:50
all letters with color
01:32:52
color colors dot primary
01:32:56
then
01:32:57
const
01:32:59
yellow caps
01:33:02
is get all letters with color colors dot
01:33:06
secondary and our black
01:33:11
caps
01:33:12
or letters or keys i don't know
01:33:16
is get all letters with color colors dot
01:33:21
is it black or dark gray
01:33:23
i think it's dark gray
01:33:27
yes it's dark green
01:33:29
so now we can send them to
01:33:33
yellow and the last one is
01:33:36
gray caps
01:33:38
let's rename it gray here
01:33:46
gray caps
01:33:47
boom
01:33:48
all right we have it so
01:33:50
if i refresh the game
01:33:52
initially all of them keys are activated
01:33:57
if i write something all right h is
01:34:00
there
01:34:01
but these
01:34:02
four letters they are grayed out and the
01:34:05
thing is that we can not even press on
01:34:07
them because they are
01:34:09
obviously not in the word so let's try
01:34:12
another thing like i don't know and
01:34:15
enter
01:34:16
boom we see green uh letters which means
01:34:19
that's good
01:34:21
okay
01:34:23
enter and we are done
01:34:26
not with a build we still have a couple
01:34:28
of things to to implement but we've
01:34:31
with coloring our keyboard
01:34:36
any reason why not i use get cell
01:34:38
background color to also set green caps
01:34:41
yellow caps is a dessert
01:34:45
um
01:34:51
get background color
01:34:55
the thing is that
01:34:57
like keyboard is a separate component
01:34:59
and i
01:35:01
i
01:35:02
didn't want to involve a function call
01:35:04
here i just wanted to i know i thought
01:35:07
this is the easier way like we send here
01:35:10
an array of i don't know
01:35:12
a couple of keys and we know that this
01:35:15
keys should be with green
01:35:18
easy easy same thing with yellow and
01:35:21
gray caps
01:35:26
can you make a video on rack native
01:35:28
performance optimization that's an
01:35:30
interesting topic we could um definitely
01:35:33
do something like that in future
01:35:37
is the application uh responsive on all
01:35:39
device sizes
01:35:42
i tried my best to do it responsive
01:35:45
you can give it a try
01:35:47
like
01:35:49
map height 100 it shouldn't be here map
01:35:53
should
01:35:54
match the height of everything
01:35:56
um
01:35:58
but yeah like everything is responsive
01:36:01
it depends on the screen size and also
01:36:03
we have a max weave for i don't know if
01:36:05
you run this application on um
01:36:08
ipad like it's gonna look still good it
01:36:11
will not have giant
01:36:13
um
01:36:15
keys there
01:36:19
what happens when current row exceeds
01:36:21
rose length yeah that's uh that's
01:36:23
possible
01:36:25
nothing will happen at the moment
01:36:27
we will just not be able to
01:36:30
oh probably
01:36:31
undefined is not an object yeah we'll we
01:36:33
will have an error
01:36:35
but that's our next task the next next
01:36:38
task is to
01:36:40
handle
01:36:41
um the game states if we won or if we
01:36:45
lost
01:36:47
and um
01:36:48
let's see if we have any other
01:36:50
comments
01:36:55
in get cell background color we already
01:36:58
have a greens and yellows
01:37:00
yeah
01:37:01
maybe maybe that
01:37:04
if you find a better way to do it like
01:37:06
go ahead and also send me
01:37:08
a screenshot or send me um the code for
01:37:11
for for it because i don't say that this
01:37:14
is uh the best way to to implement it or
01:37:18
the the most performant way like this is one
01:37:21
way and if you can think of another way
01:37:24
that's also
01:37:32
valid so guys let's continue and we're
01:37:36
going to continue with
01:37:38
win and lose
01:37:40
game states right
01:37:43
so when that should happen
01:37:45
uh
01:37:46
when should we check
01:37:48
if it's win or loss
01:37:50
we need to check that
01:37:54
uh
01:37:55
whenever we
01:37:56
go to the next row
01:37:58
so as you can
01:38:01
see here like i write something then i
01:38:04
press enter i go to the next row and now
01:38:07
i need to check did i win or did i lose
01:38:11
so for that reason i'm going to
01:38:14
use the use effect hook
01:38:18
to execute the logic of checking the
01:38:21
game state
01:38:22
when our current row changes
01:38:27
but this use effect will also be updated
01:38:30
in the first
01:38:31
the first time so we need to check if
01:38:34
current row is more than zero
01:38:38
then check
01:38:40
game state
01:38:44
all right let's implement this check
01:38:46
game state i don't know where
01:38:49
let's scroll a bit down
01:38:53
we already have a lot of things here i
01:38:55
don't know let's declare it somewhere
01:38:57
here check game state
01:38:59
and that's it
01:39:03
then we are going to have two more
01:39:10
function check if
01:39:12
one
01:39:14
equal to a function
01:39:16
and const check if lost
01:39:21
is a function
01:39:24
check if one
01:39:26
[Music]
01:39:29
yeah here let's do if
01:39:31
check if one will return true
01:39:34
then what do we have to do let's start
01:39:36
with a simple alert
01:39:38
um hooray
01:39:43
you won
01:39:48
else
01:39:50
if
01:39:51
check
01:39:53
if lost
01:39:56
alert
01:40:01
try again
01:40:03
tomorrow
01:40:07
okay now nothing will happen but if we
01:40:09
will implement this check if one um
01:40:13
so we need to
01:40:14
check
01:40:15
if every letter
01:40:18
uh so let's say that i add something
01:40:21
here enter
01:40:23
try again tomorrow oh i didn't call this
01:40:26
check if lost
01:40:28
now it's better
01:40:31
so if every letter of our previous row
01:40:35
because we already moved to the next one
01:40:37
and we need to check the previous one
01:40:42
so i can do const row equal to rows
01:40:46
add position
01:40:49
current row minus one
01:40:54
so we are now on the row number one with
01:40:58
the index one
01:41:00
we get
01:41:01
the row from the previous row from the
01:41:03
previous position which is at position
01:41:05
zero and we need to check
01:41:08
this word
01:41:10
we are going to do
01:41:12
use some
01:41:13
handy javascript methods and we are
01:41:15
right away gonna return
01:41:17
so let's return
01:41:19
true if
01:41:21
every
01:41:22
character in our row
01:41:25
every letter in our
01:41:27
row
01:41:29
is the same as the
01:41:32
letter
01:41:35
from our word
01:41:37
letters
01:41:42
i don't know if we
01:41:43
need letter letters where do we use it
01:41:48
letters here
01:41:49
letters column
01:41:58
maybe
01:41:59
we could use it as an array
01:42:02
so uh check if one if letter is equal to
01:42:06
letters at the same position but what is
01:42:08
the position of
01:42:10
this letter
01:42:11
well we can get it
01:42:13
the same way as we did it previously by
01:42:16
taking the i here
01:42:19
so at position i
01:42:22
so if
01:42:23
every letter from our row
01:42:27
here
01:42:32
well i already saw an issue there
01:42:35
did it say that we won no
01:42:40
no that's good so let's
01:42:43
try it like this
01:42:45
enter
01:42:47
now if every letter from this row
01:42:51
letter
01:42:52
is equal to the letter from the word
01:42:54
that we're trying to guess but at the
01:42:56
same position
01:42:58
then we won otherwise we didn't so let's
01:43:02
try uh the one state hello enter hurray
01:43:07
u1
01:43:08
good that's awesome now let's check uh
01:43:11
do that check if lost as well
01:43:15
when did we lose we lose we lost if we
01:43:18
didn't win and we are at the
01:43:22
um return
01:43:25
at the current row basically if we
01:43:28
overflow the rows if we have six tries
01:43:31
but now we are at the
01:43:33
current row
01:43:34
um
01:43:39
rows with of length
01:43:44
so we if currently we are
01:43:47
past the number of rows
01:43:50
then we
01:43:51
lost
01:43:54
let me refresh
01:43:56
and try again
01:44:08
now we are the current row is equal to
01:44:11
rows minus
01:44:13
rows length minus one because the first
01:44:16
one is zero one two three four five but
01:44:20
the length is six
01:44:22
and now if i will press enter we will go
01:44:24
to the current row six which is going to
01:44:26
be equal to rows
01:44:28
and the first thing we will check if we
01:44:31
won otherwise we will check if we lost
01:44:34
so
01:44:35
we
01:44:36
if i press enter ah try again tomorrow
01:44:41
all right the
01:44:43
lost situation works as well
01:44:50
like throw the value packed content well
01:44:53
always a pleasure thank you very much
01:44:54
it's my pleasure as well to
01:44:57
to share with you
01:45:00
anyone can tell me this life will be
01:45:02
saved on youtube yes yes and yes we are
01:45:05
saving all the live streams um
01:45:08
on the channel so you can go back watch
01:45:10
it on your own pace i understand that
01:45:12
now in the live stream i'm trying to go
01:45:14
a little bit faster
01:45:16
but after that you can pause and go
01:45:20
on actually your own pace
01:45:24
okay so we have a winning state we have
01:45:27
a lost state um
01:45:29
[Music]
01:45:31
shall we save it in
01:45:33
in an actual state variable like what is
01:45:36
the state of the game because now there
01:45:38
is an issue if i do
01:45:40
hello
01:45:43
wait hello
01:45:45
we won but we can go
01:45:48
and play
01:45:49
further
01:45:50
so i think oh i think we will need a
01:45:53
state variable
01:45:54
const
01:45:56
game state
01:45:58
set
01:45:59
game
01:46:00
state
01:46:01
equal use
01:46:03
state
01:46:05
um
01:46:08
what can be the potential states one is
01:46:12
game over
01:46:16
no no let's do
01:46:17
easier one lost and playing
01:46:21
these are with three possible
01:46:24
states initially it's game state playing
01:46:29
um
01:46:33
if check is win we display that and we
01:46:36
set
01:46:37
game state
01:46:39
to 1
01:46:41
and if we lost we set gamestate to
01:46:46
lost
01:46:50
ok
01:46:51
now
01:46:52
on key pressed first of all we need to
01:46:55
check
01:46:57
if
01:46:58
game state is equal to
01:47:01
playing
01:47:04
now if gameplay
01:47:06
if game state is different when playing
01:47:07
then we want to stop we don't want to
01:47:10
execute the function
01:47:12
now if i'm gonna do
01:47:14
hello
01:47:16
enter
01:47:17
we won and we will not be able to
01:47:20
enter any more
01:47:22
data
01:47:26
let's see
01:47:42
okay okay okay
01:47:46
um
01:47:47
what's the next step
01:47:55
i think we are almost there
01:48:02
we are almost there
01:48:05
do we need anything anything extra
01:48:12
what is the best way for you to improve
01:48:15
your coding skills before you are good
01:48:17
at it
01:48:21
i know let me address it so the question
01:48:23
is what was the best way for you to
01:48:25
improve your coding skills before you
01:48:28
are good at it
01:48:30
so my idea is that the best way to
01:48:33
improve your coding skills is by
01:48:36
building
01:48:37
actual real real world projects
01:48:40
i don't know you most definitely have an
01:48:43
idea
01:48:44
of an application that you are you want
01:48:46
to build like it's your dream like that
01:48:49
is what motivates you to start learning
01:48:51
coding
01:48:52
why not start it while learning coding
01:48:55
and that will
01:48:57
uh speed up your process of learning so
01:49:00
much because you
01:49:01
have a goal of building an application
01:49:03
you will learn and you will
01:49:05
research over the way a lot of things
01:49:08
and by doing that you will learn and you
01:49:10
will not get bored and the bonus point
01:49:12
is that event you will have a working
01:49:14
application
01:49:20
so if
01:49:23
that's also how i
01:49:25
learned coding
01:49:28
mostly for building projects for
01:49:30
building startups that i was passionate
01:49:32
about and
01:49:34
even why like i when i started like i
01:49:37
was
01:49:39
like zero i didn't know any programming
01:49:44
like i slowly got the fundamentals and
01:49:46
then right away started building
01:49:48
projects
01:49:58
all right
01:50:06
what i wanted to show you next is how we
01:50:09
can share the result because i think
01:50:12
this is a little trick and it's pretty
01:50:15
cool
01:50:16
and
01:50:17
sharing these results on twitter i don't
01:50:20
know if you saw them
01:50:22
let me show you
01:50:24
this in my opinion contributed to the
01:50:27
most
01:50:29
growth
01:50:30
because
01:50:32
you saw for example in my case i saw so
01:50:35
many squares like this in my feed
01:50:38
uh
01:50:39
yeah square like this or let's open even
01:50:42
wordle here
01:50:45
like so many squares let me say i was
01:50:46
like what is this like i don't
01:50:48
understand what's happening
01:50:51
and this made a lot of people google it
01:50:53
and
01:50:54
actually start playing uh themselves
01:50:57
so i think that it's a really smart
01:51:00
feature of
01:51:01
sharing um like your score in this way
01:51:05
without
01:51:07
and having this
01:51:10
how's it called
01:51:12
mystery mystery
01:51:14
in the shared message because it it's
01:51:16
nowhere like a link to the game there is
01:51:18
nowhere
01:51:20
actually there is the name wardle but
01:51:22
that's it like that's the only thing
01:51:25
so um let's see how we can do the same
01:51:28
in our application
01:51:30
uh
01:51:31
well for that like they are the way they
01:51:34
are doing it we are not actually sharing
01:51:36
it we are just putting this text in your
01:51:39
clipboard
01:51:40
and after that you can go to twitter
01:51:42
facebook or anywhere and paste that
01:51:44
message manually
01:51:46
that's how we're gonna do in our
01:51:48
application as well
01:51:50
and for
01:51:52
for that reason we are going to install
01:51:55
a package
01:51:57
let's open the terminal and let's add a
01:52:00
new one no let's better stop our server
01:52:03
because we will still need to restart it
01:52:05
and do expo
01:52:07
install
01:52:09
uh
01:52:10
and it's called export dash clipboard
01:52:13
expo install export clipboard
01:52:25
all right we have
01:52:27
initialized
01:52:28
install the clipboard package
01:52:31
now where will that functionality be of
01:52:34
sharing well uh when we say u1
01:52:38
let's add a button so for the alert if
01:52:40
you want
01:52:42
but did we import the alert yes we did
01:52:46
the three parameters
01:52:48
in an alert is the list of buttons and
01:52:51
we need to provide an array
01:52:53
and each button is an object so let's
01:52:56
say the button is going to be have a
01:52:59
text of share
01:53:01
and now on press will be i don't know
01:53:05
share
01:53:07
score
01:53:09
let's take this function and implement
01:53:11
it somewhere here
01:53:13
cost share score equal
01:53:18
all right
01:53:20
and
01:53:21
let's try to
01:53:24
compose this
01:53:26
uh this
01:53:28
text
01:53:29
how we're going to do that so um
01:53:32
well we have this
01:53:34
rows we have
01:53:36
the representation of map in our
01:53:39
state
01:53:40
well const
01:53:42
text to share
01:53:45
is going to depend on our rows so rows
01:53:48
let's map through
01:53:50
every row in that
01:53:52
um in that array and we will need the
01:53:56
position as well
01:53:58
and then for every row we need to map as
01:54:01
well
01:54:03
through the
01:54:07
cell and then j
01:54:11
well you know what let's simply take the
01:54:13
background color of that cell so
01:54:17
get
01:54:19
background get cell background of i and
01:54:23
then j
01:54:24
this is going to give us the background
01:54:25
color
01:54:27
and we can simply cancel log
01:54:31
text
01:54:33
to share
01:54:37
let's have a look
01:54:39
oh we need to restart the server no not
01:54:43
like this npm start
01:54:49
vadim you are putting out content that's
01:54:51
too good to be true the best rack native
01:54:53
projects on youtube period thank you
01:54:55
very much thank you thank you a lot for
01:54:57
appreciating my hard work uh
01:54:59
i'm trying my best to provide as much
01:55:03
value as possible
01:55:04
here on youtube and i'd really
01:55:06
appreciate if you yeah let's
01:55:09
do it
01:55:10
let's all hit the subscribe button down
01:55:12
below if you uh take some value out of
01:55:16
my videos that i produce here
01:55:18
and that will help me tremendously like
01:55:21
we i have a goal to reach 100k by the
01:55:24
end of this year and with your help i
01:55:27
believe that we can do it
01:55:30
so it's free uh you can do it right now
01:55:34
and uh yeah do it why not subscribe
01:55:37
subscribe
01:55:40
all right and we have our application
01:55:42
back uh here
01:55:44
let's
01:55:47
refresh it
01:55:57
i'm gonna do a couple of things here
01:55:59
enter
01:56:00
[Music]
01:56:02
enter and then let's do
01:56:04
hello
01:56:07
enter
01:56:08
share if i press share we should see i
01:56:11
don't see any console log because i
01:56:12
didn't select iphone
01:56:14
from here so select your device and now
01:56:17
we will see the background color here
01:56:21
so
01:56:23
yeah we see a lot of things
01:56:25
but
01:56:26
first row second one and third one
01:56:29
this is all the greens that we have
01:56:31
there
01:56:33
um
01:56:38
well uh how to proceed look um
01:56:43
i made
01:56:45
in the our constants
01:56:47
i made um
01:56:51
a map
01:56:52
a simple javascript object that serves
01:56:55
as a map where the key is our color
01:56:59
for example dark gray
01:57:01
and the value is one of these squares
01:57:05
now using these colors to emoji we can
01:57:07
simply map
01:57:09
from these values
01:57:11
to the squares that you saw there
01:57:15
let's try to do that
01:57:16
let's in our app.js
01:57:19
import
01:57:21
colors to emoji
01:57:24
and where we have a share
01:57:26
here
01:57:28
so we we get the background color
01:57:31
and now we using the colors to emoji we
01:57:34
simply map
01:57:35
we say give me the emoji that
01:57:38
corresponds to this color
01:57:41
we have a color
01:57:43
we want back an emoji
01:57:46
that's what's happening here
01:57:50
let's have a look
01:57:53
uh
01:57:54
if i
01:57:56
clear everything and i press share
01:57:58
all right
01:57:59
we see something happening that's good
01:58:01
because the third array contains only uh
01:58:05
green things
01:58:07
and as you can see like it matches our
01:58:10
map here like undefined here yeah there
01:58:13
is no color there
01:58:16
okay um
01:58:18
so now
01:58:20
let's see how we can
01:58:22
from an array of icons
01:58:26
get a string of these icons merged
01:58:29
together
01:58:30
to do that we can call join operator on
01:58:34
an array
01:58:35
our array is going to be this one a
01:58:38
row.map will return an array and we can
01:58:42
dot
01:58:43
join
01:58:45
and you can say here how do you want to
01:58:47
join if you want comma add a comma here
01:58:50
and now if i press share
01:58:56
it's not there why what what
01:59:00
join okay
01:59:03
share
01:59:05
all right now they're gonna be merged
01:59:07
with a comma
01:59:09
the thing is that we don't want any
01:59:11
space between them so we're gonna just
01:59:13
join on um
01:59:14
using an empty uh array an empty string
01:59:18
that will give us this array
01:59:22
now this array we need to merge
01:59:25
uh
01:59:27
no first of all let's filter this
01:59:30
rows that do not have anything
01:59:33
so i'm gonna do
01:59:35
like this rows.map
01:59:38
dot
01:59:41
dot
01:59:42
filter of
01:59:45
row
01:59:46
if row doesn't have anything
01:59:48
filter only if it has something will it
01:59:50
work like this
01:59:52
share
01:59:54
yes
01:59:55
it capped only the rows that contain the
01:59:58
value
02:00:00
now
02:00:02
this is still an array
02:00:04
so we want to join it
02:00:07
but how do we want to join we want to
02:00:08
join it with uh enter with a new line
02:00:12
character
02:00:14
let's have a look at the
02:00:16
new line uh code i don't know how is it
02:00:20
called yeah
02:00:21
is it simply like that
02:00:24
join with uh backslash and
02:00:28
let's see if
02:00:29
it actually works
02:00:31
let's have a look at our
02:00:33
here share
02:00:35
yes
02:00:36
yes it works come on let's go
02:00:40
now that we have this text to share
02:00:46
where is my code here
02:00:49
now that we have this text to share we
02:00:51
can simply do
02:00:52
first of all import the clipboard
02:00:55
border color i don't need it here
02:00:58
import
02:01:00
uh clipboard
02:01:01
from react native not react native web
02:01:04
but
02:01:06
from expo clipboard
02:01:10
from here
02:01:14
now share score we can do
02:01:18
clipboard
02:01:19
dot
02:01:20
set text
02:01:22
or how is it called
02:01:25
um
02:01:26
clipboard
02:01:30
let's uh check the documentation word
02:01:32
let me quickly check it here
02:01:38
set string
02:01:41
set
02:01:42
string
02:01:43
to that text share that we are trying to
02:01:45
share
02:01:46
and after that we can also do alert
02:01:48
alert i don't know
02:01:52
mess
02:01:56
your score
02:02:02
what to say there copied successfully
02:02:06
that's how i write successfully i can
02:02:08
never write successfully
02:02:10
success sec
02:02:13
success
02:02:15
it should be never seen
02:02:17
double oh my god i did it
02:02:21
share your
02:02:24
score on your social media
02:02:29
save
02:02:30
all right we won let's press share
02:02:34
let's refresh our application
02:02:37
something is going on here
02:02:39
so this is my first try enter and this
02:02:43
one enter when this one enter and then
02:02:49
low enter
02:02:51
amazing we won share
02:02:54
and define is not an object evaluating
02:02:56
expo clipboard clipboard set string
02:03:01
4k
02:03:07
we
02:03:08
install this expo clipboard let's check
02:03:10
package.json expo clipboard yes it's
02:03:13
there
02:03:14
oh probably we will need to
02:03:17
restart and clear the cache so npm start
02:03:23
clean or clear yeah clear
02:03:29
and let's
02:03:31
close application completely
02:03:33
and run it again
02:03:46
so right now let's give it a test
02:03:49
enter
02:03:51
enter
02:03:56
enter
02:03:58
and hello
02:04:00
and
02:04:02
hello enter
02:04:04
share
02:04:05
and find is not an object why expo
02:04:07
clipboard set string once again i'm
02:04:10
coming back i need to
02:04:12
go somewhere very important so stay
02:04:14
tuned i'm coming back we will fix this
02:04:16
issue
02:05:04
right i'm back let's um see once again
02:05:08
what's the issue
02:05:14
um oh i think that the way
02:05:18
it is imported
02:05:20
so
02:05:21
oh yes i imported it like this
02:05:25
by the structuring but we need to import
02:05:27
everything as clipboard
02:05:29
and now if i do share
02:05:31
copied successfully now let's go into
02:05:34
another application
02:05:38
for example messages
02:05:41
and paste it here
02:05:43
paste
02:05:44
boom
02:05:45
that's it
02:05:48
i don't know who i'm texting there
02:05:51
but hopefully it's not some of my
02:05:53
numbers
02:05:54
um
02:05:55
yeah for the shared text you can also i
02:05:58
don't know add some
02:06:02
something in the beginning like this is
02:06:04
the
02:06:06
map
02:06:07
that map
02:06:09
to
02:06:12
text map
02:06:13
or
02:06:14
rows
02:06:16
and then text
02:06:19
to
02:06:20
share equal
02:06:23
it can be
02:06:24
like
02:06:25
wordle
02:06:28
of the number of days i think they are
02:06:32
seeing and something like that
02:06:34
but i'm gonna keep it simple
02:06:38
text map
02:06:47
where is my application
02:06:57
what's happening
02:07:00
all right
02:07:03
enter and then hello
02:07:07
enter
02:07:08
share
02:07:10
copied okay
02:07:14
paste and now it will contain some
02:07:18
one extra space but
02:07:20
you've got the idea
02:07:23
that's how we can implement the share
02:07:25
mechanism
02:07:26
similar to the wordle game
02:07:31
you have to empty the clipboard first
02:07:35
do you
02:07:37
if you just set string it will simply
02:07:39
override
02:07:48
okay all right
02:07:54
what else
02:08:00
there is a small issue that i can show
02:08:03
you how to fix
02:08:05
and i cannot show you exactly how and
02:08:09
when it happens for example if i do some
02:08:11
change small changes in the application
02:08:14
and i save
02:08:15
uh i see
02:08:17
the u1 message once again
02:08:20
so that would happen only if the
02:08:24
application re-renders
02:08:26
in that win state
02:08:29
to
02:08:32
fix that what we can do
02:08:35
is
02:08:36
[Music]
02:08:38
simple a simple way
02:08:41
would be
02:08:42
to check here
02:08:49
if check one
02:08:50
and uh
02:08:52
game state
02:08:55
is different
02:08:57
than
02:08:58
one
02:09:01
vendo vis
02:09:02
check if lost and
02:09:05
game state
02:09:06
that's basically don't repeat the same
02:09:09
the same
02:09:10
step game step is
02:09:13
different
02:09:14
than
02:09:15
lost
02:09:16
then do this but because we added
02:09:19
another check i think that the best way
02:09:22
would be in the check if lost
02:09:26
to first of all check if if a user won
02:09:29
so
02:09:30
um
02:09:34
check if
02:09:36
one
02:09:38
and that
02:09:41
he lost if he didn't already win
02:09:44
and if he is over
02:09:47
that limit
02:09:48
now if i'm gonna try a couple of
02:09:54
enter
02:09:55
enter
02:09:57
enter
02:09:59
let me try to lose enter
02:10:04
enter
02:10:05
try again okay and if i'm gonna change
02:10:08
some
02:10:09
something here i don't know
02:10:11
save
02:10:12
i'm not gonna see that message again
02:10:15
because we are checking
02:10:17
um
02:10:20
we are showing the alert
02:10:22
when we lost but only
02:10:24
the first time we lost like if we are
02:10:26
already in the lost state we don't show
02:10:29
it one more time
02:10:31
the same should happen with them
02:10:35
winning state
02:10:36
hello enter we won share
02:10:40
okay
02:10:41
now if i do some changes
02:10:43
refresh nothing happens
02:10:47
uh
02:10:48
oh i have to empty the clipboard when i
02:10:51
had to go away yes yes
02:10:54
exactly all right
02:11:01
[Music]
02:11:04
so
02:11:05
that is mostly everything that i wanted
02:11:07
to show you what else we can implement
02:11:10
or improve uh the way we take the word
02:11:14
so that's that's something interesting
02:11:17
um the way i think with the easiest
02:11:20
the easiest way to
02:11:22
select the daily word
02:11:24
is just to simply have like words which
02:11:28
is an array
02:11:29
of i don't know hello
02:11:33
world and so on
02:11:38
um and then
02:11:41
when we launch the application we will
02:11:43
select the word based on the
02:11:46
current date
02:11:48
so
02:11:49
let's have a look how we can no based on
02:11:52
them
02:11:54
what
02:11:56
the number of a day in a year so if it's
02:11:59
15 january that's the 15th word
02:12:04
if it's
02:12:06
if it's 15 february that's somewhere
02:12:09
like 45 or i
02:12:12
i don't know the math but you get the
02:12:14
idea so i'm gonna search something like
02:12:17
javascript
02:12:20
get day of the year i think i found some
02:12:23
functions i don't want to reinvent the
02:12:25
wheel here
02:12:27
i will simply
02:12:32
take one of these
02:12:38
i think this one is simple enough
02:12:41
they say that it has an issue with
02:12:48
during the october
02:12:50
during the daylight saving switch but it
02:12:53
doesn't matter for us so i'm gonna have
02:12:56
this function here
02:13:03
const get day
02:13:07
of
02:13:08
the year
02:13:14
i will
02:13:15
move everything to cost because
02:13:17
we do not use var
02:13:19
anymore
02:13:21
and now we take the date
02:13:24
we then move to the beginning of the
02:13:26
year
02:13:27
we check the difference between now and
02:13:29
the beginning of the year
02:13:33
we calculate
02:13:34
how many seconds is one day and then we
02:13:37
calculate the number of days based on
02:13:40
that difference in seconds that's simply
02:13:42
how it works and we can return day
02:13:49
now
02:13:51
our selected word
02:13:55
um
02:13:59
so const
02:14:01
day
02:14:02
of the year
02:14:04
equal get day over here
02:14:07
and then the word will be
02:14:10
words
02:14:11
at the position day of the year
02:14:14
the thing is uh
02:14:16
i need to input more words here
02:14:20
so
02:14:21
i don't know
02:14:24
let me just copy paste this multiple
02:14:27
times
02:14:29
to have enough words
02:14:34
all right and it works now let's check
02:14:37
if it's hello or word hello enter
02:14:41
boom we
02:14:43
have done it if i'll remove the first
02:14:45
one
02:14:46
that will mean that the current word is
02:14:48
a different one
02:14:50
because it's a different day
02:14:52
and now
02:14:53
i will have to guess them whoa
02:14:57
come on
02:14:59
oh i was in them one state
02:15:04
world
02:15:07
enter
02:15:08
hey we won
02:15:11
all right now the only step is to
02:15:13
actually fill in um
02:15:16
365
02:15:17
words here
02:15:19
and i think that i'm gonna i'm gonna
02:15:22
fill in these words and i'm gonna deploy
02:15:24
this application on market and i'm gonna
02:15:27
do it with uh some programming words so
02:15:30
that everyone can have some fun with uh
02:15:32
trying to get some programming keywords
02:15:35
i'm gonna spend some time to to find
02:15:38
some really nice words um names of some
02:15:40
algorithms and then we will
02:15:43
i will try to deploy it
02:15:45
let's hope that i'll have time to um to
02:15:47
do that
02:15:49
but yeah that's uh the easiest way that
02:15:52
we can manage words
02:15:54
um
02:15:55
of course if you want a different way
02:15:58
like you could um have a back end where
02:16:01
you store all the words and then from
02:16:04
the application you just query the back
02:16:05
and get the current word and uh work
02:16:08
with it
02:16:09
um
02:16:11
this way like if we have to add more
02:16:14
words we will have to build again the
02:16:16
application and publish it again on
02:16:18
market
02:16:20
but with the help of expo we can do
02:16:24
these updates over the air which means
02:16:26
that the user will not have to reinstall
02:16:29
the application we will not submit a new
02:16:32
build we simply will
02:16:34
submit a new
02:16:35
javascript bundle that will be
02:16:39
downloaded by expo
02:16:41
when the application will first launch
02:16:43
when the application will launch on the
02:16:44
device so that's not a big issue
02:16:48
uh all right so other things that you
02:16:51
can improve on this game uh and things
02:16:54
that
02:16:56
i will leave you as a homework to
02:16:58
practice let me grab something and i
02:17:02
will write you
02:17:04
or let me do it right here
02:17:09
let's do a
02:17:12
readme dot md
02:17:20
okay
02:17:22
react native
02:17:26
wordle game in react
02:17:29
native
02:17:31
uh here is
02:17:34
homework
02:17:38
um
02:17:39
one
02:17:41
thing that you could improve is
02:17:43
save
02:17:44
current progress
02:17:46
in async
02:17:49
storage
02:17:51
so that um
02:17:56
if you close the application
02:18:00
in the middle of the game
02:18:04
and then
02:18:05
re launch
02:18:08
you continue
02:18:10
from where you started
02:18:14
this will um yeah this will
02:18:18
prevent
02:18:20
cheating
02:18:22
this will prevent cheating because
02:18:25
now you could try some different
02:18:27
letters check them close the application
02:18:30
open it again and do the word from the
02:18:32
first try but if you save a progress in
02:18:35
a sync storage then you will
02:18:41
yeah make sure that this is not
02:18:43
happening
02:18:45
your goal is just to subscribe
02:18:48
hello catalin how is it going
02:18:54
um
02:18:56
another thing would be
02:18:58
uh
02:18:59
keep track
02:19:01
of the
02:19:03
of
02:19:04
all the
02:19:09
of the score and
02:19:11
streaks
02:19:13
so for
02:19:14
for example
02:19:15
in wordle if i will
02:19:18
open it
02:19:22
wordle
02:19:26
there are so many already uh what is the
02:19:28
original one ordeal
02:19:31
language i don't know
02:19:35
power language
02:19:38
so if i do i remember the word from
02:19:40
today it was something like berkey
02:19:45
enter
02:19:48
okay and we will see the statistics oh my god
02:19:52
enter
02:19:54
or here yes
02:19:56
statistics this shows the number of
02:19:59
games played
02:20:00
let's add that to our project keep track
02:20:04
of
02:20:05
um
02:20:07
stats
02:20:09
number of games played
02:20:13
what else you can add
02:20:16
win rate
02:20:18
you can calculate based on how many
02:20:20
times you won
02:20:22
current straight
02:20:26
max
02:20:28
straight streak straight strict how do
02:20:31
you pronounce it i don't know
02:20:34
and um yeah that's it so if you can keep
02:20:37
track of these stats you can also do
02:20:39
them in a sync storage like
02:20:42
of course it could be better with a
02:20:43
database because you will you with a
02:20:46
database you will never lose this data
02:20:48
but with a sync storage that's also good
02:20:52
you can also keep them there
02:20:55
because it's not like i don't know some
02:20:57
very important data that you are afraid
02:20:59
of losing because if
02:21:02
with a sync storage if a person
02:21:04
uninstalls the application then he will
02:21:06
lose this data
02:21:10
what else
02:21:11
animations
02:21:14
animations
02:21:15
uh
02:21:16
for the letters for the words and so on
02:21:20
um what else can you do
02:21:23
um
02:21:27
this is already more advanced like
02:21:32
more advanced
02:21:34
and needs
02:21:36
some
02:21:38
backend
02:21:43
public leaderboard
02:21:49
save the
02:21:51
stats in
02:21:52
a database
02:21:56
uh public leaderboard to see
02:21:59
who is the first one and so on
02:22:02
hey guys recommend some additional
02:22:04
features that we we could add here
02:22:21
um yeah i don't remember
02:22:24
what other things we could
02:22:27
check here
02:22:30
if you add
02:22:32
i'm gonna add it somewhere here
02:22:36
if you um add
02:22:38
a big
02:22:45
if
02:22:46
you add a big data
02:22:51
set of words
02:22:53
you can also check
02:22:56
um
02:22:57
if the
02:22:58
and
02:22:59
entered
02:23:01
word
02:23:02
is a valid word and what i mean here is
02:23:05
for example in wordle
02:23:07
uh let me try again
02:23:11
if you
02:23:13
were the
02:23:14
power language if you'd write some very
02:23:17
random letters and you press enter
02:23:20
nothing is happening because it says
02:23:22
the word is not in the list so it should
02:23:25
be some valid words to to be able to to
02:23:29
enter
02:23:30
so
02:23:31
you could implement that as well but
02:23:33
only if you have a big enough uh data
02:23:36
set of words because if you have like i
02:23:38
don't know 10 words
02:23:39
and
02:23:40
you implement this feature i don't think
02:23:42
it's going to be good because
02:23:45
people will not be able to guess the
02:23:47
words that exactly you put there and
02:23:49
it's going to be frustrating that's what
02:23:51
i think
02:23:53
and yeah if you have any other ideas
02:23:55
please implement them uh
02:23:58
that way
02:23:59
you will learn much more
02:24:01
by by doing by doing extra features by
02:24:04
going that extra mile uh by being
02:24:06
curious and saying like what will happen
02:24:09
if i do that or if i add one extra rule
02:24:12
to this game it will be more fun i don't
02:24:15
know
02:24:16
be creative
02:24:17
and uh implement it and show me show me
02:24:20
a demo send me um
02:24:22
on my email or on social medias send me
02:24:25
your
02:24:26
github repositories i'm gonna have a
02:24:28
look and if you also publish the game
02:24:30
you can um you can send it to me if you
02:24:32
want to play this game uh at the moment
02:24:35
but no uh we're not gonna do that
02:24:38
because i will try my my best to
02:24:41
release this game soon
02:24:44
i don't know how soon but i will try
02:24:50
and um yeah i think that was it guys for
02:24:52
today that was everything that i wanted
02:24:54
to to show you uh subscribe to the
02:24:57
channel down below not to miss future
02:24:59
videos because we have a lot of plans
02:25:01
for 2021 uh we have lucas on our team uh
02:25:05
we have our team members that are
02:25:07
helping us create more and better
02:25:10
content and we're going to try our best
02:25:12
to make sure that this year like we all
02:25:15
grow together as a community
02:25:19
and we achieve new new highs together
02:25:22
and
02:25:23
the only thing that i ask you is to
02:25:25
subscribe to the channel and the rest
02:25:27
i'm gonna come with
02:25:29
fire videos with value packed tutorials
02:25:33
as this one um later in the future
02:25:36
and
02:25:37
yeah let's roll the outro where is it
02:25:39
outro here it is uh while you're
02:25:42
watching for the next video you can
02:25:44
watch
02:25:45
this video or this video they're both
02:25:47
amazing tutorials that will teach you
02:25:50
uh rack native and amplify development
02:25:53
for mobile development and yeah
02:25:56
take care stay hydrated write clean code
02:25:58
and i'm out bye

Description:

Learn how to build a WORDLE game in React Native. The tutorial is great for both beginners, and for developers familiar with React Native. We will walk you through all the steps to build the app from scratch. 📚 Enroll NOW for "The Full-stack Mobile Developer" and save 30% https://academy.notjust.dev/ 🎒 Source code and Asset Bundle: https://assets.notjust.dev/wordle 💬 Join the notJust Development gang and let's build together https://discord.com/invite/VpURUN2 Tag me on social media when you finish this build, and I will give you feedback on your project. Twitter: https://twitter.com/VadimNotJustDev IG: https://www.facebook.com/unsupportedbrowser LinkedIn: https://www.linkedin.com/in/vadimsavin TikTok: https://www.tiktok.com/@vadimnotjustdev Timecodes: 0:00 Intro 4:00 Getting started 17:30 Importing keyboard component 20:00 Building the Game Board component 45:50 Implementing Wordle game logic 1:13:04 Color coding the board and keyboard 1:36:05 Handling game won or lost state 1:50:05 Sharing game result 2:11:04 Managing daily word selection 2:16:50 App improvements Disclaimer: This build is for educational purposes only!! All views, opinions, technology choices expressed in this video are my own and do not represent the views, opinions, technology choices of any entity whatsoever with which I have been, am now, or will be affiliated.

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Let's build WORDLE with React Native (tutorial for beginners) 🔴" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Let's build WORDLE with React Native (tutorial for beginners) 🔴" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Let's build WORDLE with React Native (tutorial for beginners) 🔴" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Let's build WORDLE with React Native (tutorial for beginners) 🔴" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Let's build WORDLE with React Native (tutorial for beginners) 🔴"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Let's build WORDLE with React Native (tutorial for beginners) 🔴"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.