For a long time, I wanted to explore the React world. Today it had happened. ^_^ I must say that I am amused by the simplicity of it and React you got my attention! Since I have some experience with JS and data binding frameworks such as AngularJS and Angular, I decided to jump right in with what I usually do, learn by doing it.
So, I have decided to build a Todo app. It was really quick and easy to set it up right away. I followed the Getting Started guildline from the official site.
Initializing the todo-app
Like @angular/cli for Angular, there is create-react-app for React. I have initialized the app using the following way.
1 | $ npx create-react-app todo-app |
This created the folder and installs the default dependencies needed for an app to start. For example,
1 | "dependencies": { |
react for the React framework itselt and react-dom for DOM manipulation, I suppose.
It does come with some boilerplate code and a starter page with some links like the Getting Started and Tour of Heroes links for Angular starter page.
Create the app
Then I just started editing the stuff that was already in place and ended up with an working Todo app after an hour.
1 | // App.jsx |
To get to know the communication between components, I created a child component called TodoList which worries about displaying the list of todos alone.
1 | // todo-list.jsx |
I am surprised to see that it was done within a few lines of code. O_O I like it really! I am already feeling cheating on Angular >_O
1 | // index.js |
That is it! A working todo app in few hours, mostly because I was bit adament on fixing few things on my own by trail and error. I like it that way as it makes me to think logically and it becomes hard to forget once you found the solution after a struggle for some time on your own! O_o