Are you planning to learn React? If yes, these 35 tweets can make the process easier for you👇🏻

Long Thread🧵
If you just started or planning to getting started with React, this thread might help you.

In this thread I'll try to give you a quick overview to the world of React.

So if you find that sound interesting, give this thread a read😉

{ 2 / 35 }
Before you go further into the React, make sure to check these things

✅ Basic knowledge of HTML and CSS
✅ JavaScript fundamentals and ES6 features

I would like to suggest you build a decent hold on JavaScript concepts because that is the backbone of React

{ 3 / 35 }
So what is React?

- React is a JavaScript front-end library for building user interfaces or UI components
- A typical React app contain many components. They are reusable and can interact with each other

{ 4 / 35 }
Now the most obvious thing comes in mind is "What is component?"

📌 Component as a simple function that you can call with some input and they render some output

As they are reusable and interactable, so you can merge many components in order to make a entire React app

5 / 35
For example...

Attached image showing a typical React app with all different components.
As you can see this entire webpage is nothing but the mixture of different components

{ 6 / 35 }
In the above image there are 5 components

- Header
- Footer
- Content
- Sidebar
- List Items

I think you now have some understanding of the components

{ 7 / 35 }
Let's go further into the discussion

There are two types of components in React

1️⃣ Class based components
2️⃣ functional based components

Class-based components are defined using ES6 classes, whereas function components are basic JavaScript functions

{ 8 / 35 }
Before we breakdown each component, we need to understand difference between JS and JSX

Well, components are nothing but a JavaScript file but for our convenience we use JSX format of our components

{ 9 / 35 }
📌 JSX stands for JavaScript XML. It's basically nothing but the extension of JavaScript which allow us to write HTML code in JavaScript file.

Without JSX, creating large, nested HTML documents using JS syntax would be a tedious task that's why we use JSX

{ 10 / 35 }
const element = <h1>Hello, world!</h1>;

Consider this variable declaration. It's neither JS nor HTML. This is the mixture of JavaScript + XML = JSX

You can create JSX file with .JSX extension

{ 11 / 35 }
Now you know about JSX, let's breakdown two types of components

1️⃣ Class-based components

- Class-based components are defined using ES6 classes which implement a render function, which returns some JSX

A typical example of class based components👇

{ 12 / 35 }
2️⃣ Functional-based components

- Functional components are nothing but simply a JavaScript function which takes some parameter will return some JSX code

If looks confusing, don't worry I'll explain each line of code further in this thread

{ 13 / 35 }
Components can be further divided into two categories

🔹 Stateful components
🔹 Stateless components

As the term suggest, one has state, and the other doesn’t

{ 14 / 35 }
The Heart of every React component is "Stata" which is nothing the the object of observable properties. In simple terms we can say that state is nothing but the information/data that associated with a particular component

When the state object changes, the component re-renders
UNDERSTANDING THE VIRTUAL DOM

- You might have heard the term "DOM", virtual DOM is kind of similar. It uses a strategy that updates the DOM without having to redraw all the webpage elements

{ 16 / 35 }
Every time the DOM changes, browser need to recalculate entire layout and then repaint the web page which makes a web app slow.

To overcome this we have a virtual DOM
📌 Every time the state of our application changes, the virtual DOM gets updated instead of the real DOM

17
Whenever the new element is added to the UI, a new virtual DOM associated with that element is created. If state of this element changes, a second new virtual DOM is created which will be compared with the previous virtual DOM

- It then updates ONLY the object on the real DOM
Sounds confusing??

@moshhamedani has an amazing article on this. Give it a read

programmingwithmosh.com/javascript/sta…

{ 19 / 35 }
Let's see how we can create a React app in local machine?

- I'm assuming you have node environment set up and up-to-date version of npm. If no, download it from here

nodejs.org/en/

{ 20 / 35 }
Now we're good to go to create our first React app

- We are using Create React App, a tool that gives you a massive head start when building React apps. It saves you from time-consuming setup and configuration. You simply run one command

Install it first👇

{ 21 / 35 }
Now you have create-react-app installed in your machine, it's time to create your first React app

Command - "create-react-app app-name"

Depending upon your internet speed, this will take some minutes. So time to prepare a coffee for yourself😉

{ 22 / 35 }
Great!!🤩

After successful installation, you're terminal will show you something like this

- Open this folder in your favorite editor and then we will write our first React code🌈

{ 23 / 35 }
Run this command to start your local server and run react app

" npm start "

Your default browser will launch automatically and you will see something like this at localhost:3000

{ 24 / 35 }
You'll get many folder and files in your app. We're not going in the details as of now because that can create some confusion. You will understand each and everything automatically as you go further in the world of React

So let's start with the src folder

{ 25 / 35 }
Inside the src folder you'll get index.js file

- Remove everything inside the file
- And add this four line of code

Let me try to explain each line of code of this file👇(next tweet)

{ 26 / 35 }
- By importing React, you are telling your browser you're working with JSX so that your browser can compile it

- Import ReactDOM in order to user render method

- Import App.js so that we can print return JSX of it

- Finally render method takes two param(See attached image)
You can directly render things from inside the index.js file

* this is just from explaining purpose, don't do this in real projects

{ 28 / 35 }
- Create a folder "Components" in the src folder

This is the best practice in React, suppose you're building a complex app that have more than 10 different components, then it's good to have component folder in order to manage each and every component effectively

{ 29 / 35 }
- Inside that component folder create file(component), HelloWorld.jsx

I am gonna use functional component. You can use class component as well but functional components are new way to making your components hence I'll recomment you to write functional component

{ 30 / 35 }
- Import React so that our browser can understand we are working with JSX

- Create a function with same name as of component i.e, HelloWorld(it is best practice)

- Write your code inside HelloWorld function

CONT...

{ 31 / 35 }
- I just wanna return "hello world"

- export HelloWorld so that we can use it outside the component

{ 32 / 35 }
Import HelloWorld inside App and return it

- You will see the "Hello world" is being printed on your web page😍

Congratulations🎉 you have just taken your first step into the world of React

{ 33 / 35 }
I think time to wrap up this thread. React is so deep, it can't be explained in a single thread

But I tried my best to give a quick overview of how things work in React

I hope you get a basic overview of what components are, JSX, virtual DOM and stuff like that

{ 34 / 35 }
Next Step?

- Props and hooks.

I'll try to write a thread on them. Thanks for reading this ❤️
This is the longest thread I've ever wirtten.

If you are a beginner, my tweets can boost your learning process 🚀

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Pratham 👨‍💻🚀

Pratham 👨‍💻🚀 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Prathkum

7 Apr
Everything you need to know about CSS Flex layout

A Thread🧵 Image
Start appyling display: flex; property to parent element
This will take the all the elements in horizontal direction

{ 2 / 16 } ImageImage
You can also change the direction of elements. For doing so, you need to mention the "flex-direction" property

The flex-direction property specifies the direction of the items within the flex container

{ 3 / 16 } Image
Read 16 tweets
7 Apr
5 GitHub repositories that can help you writing better CSS code
📌 Awesome CSS Learning

- A tiny list limited to the best CSS Learning Resources

🔗 github.com/micromata/awes… Image
📌 Magic of CSS

- A CSS course to turn you into a magician

🔗 github.com/adamschwartz/m… Image
Read 6 tweets
6 Apr
16 amazing HTML attributes that are so powerful and maybe you haven't heard of them yet

🧵👇🏻
1️⃣ Type

The "type" attribute of <ol> element let you change the type of order i.e, numeric, alphabetic or roman numbers
2️⃣ Target

"Open link in new tab" by just adding 'target' attribute as "_blank"
Read 19 tweets
5 Apr
Complete resources pack to make a website from scratch

Thread🧵👇
Editors ✍️

➸ codeinterview .io
➸ codesandbov .io
➸ codepen .io
➸ godbolt .org
➸ wandbox .org
➸ carbon .now.sh
➸ pastebin .com
➸ jsfiddle .net
➸ ideone .com
➸ jsbin .com
➸ ide .judge0.com
Color picker 🎨

🔹colorhunt .co
🔸webgradients .com
🔹gradienta .io
🔸0to255 .com
🔹colors .lol
🔸colorbrewer2 .org
🔹colormind .io
🔸flatuicolors .com
🔹happyhues .co
🔸color-hex .com
🔹farbvelo .elastiq.ch
Read 10 tweets
5 Apr
Are you planning to learn Front-end development in 2021?

Here is a quick start guide 👇🏻

Thread 🧵
You can start learning web development with backend as well but starting with Front-end is more beneficial.

Well it depends on person to person. Let's move forward 🔽

{ 2 / 28 }
First things first, you need an editor to write code. There are plethora of editors out there like atom, VS code, sublime etc

I recommend you to start with VS code. Why?

Many built-in features
It's fast
Large community
IntelliSense code completion and debugging

{ 3 / 28 }
Read 28 tweets
4 Apr
Seven amazing tools / websites a developer should visit

A Thread 🧵👇🏻
1️⃣ linuxsurvival.com

Linux Survival is a free tutorial designed to make it as easy as possible to learn Linux. Even though Linux has hundreds of commands, there are only about a dozen you need to know to perform most basic tasks.
2️⃣ learn-anything.xyz

Search anything here and it will show you the correct roadmap
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!