⚡️ Day 80 ⚡️

⚡️ Let us discuss Components and Props in React.

⚡️ We will discuss each with examples.

A thread 🧵

#100DaysOfCode
{1/7}

What is a Component?

--> components are like JavaScript functions.

--> As function accepts parameters in JavaScript in the same way Component accepts props(properties) in React.

--> Components Return React elements describing what should appear on the screen.
{2/7}
--> Let us take an example.

function Greeting(props) {
return <h1>Hello, {props.name}</h1>;
}
--> If you compare it with the JavaScript function then it is same.

--> In the above example, the Component is returning the JSX expression (markup + JS).
{3/7}
--> We can define Components in two ways in React.

1. Function Components.
2. Class Components.

--> We saw the example of function component i.e

function Greeting(props) {
return <h1>Hello, {props.name}</h1>;
}
{4/7}
--> Now we will discuss how to define components using class.

e.g (see the snippet)

--> If you compare function and class-based components they both are doing exactly the same work.
{5/7}

What are the Props?

“props”(which stands for properties), like in function we pass the parameters in the same way in React we pass the props.

-> e.g

const element = <Greeting name="Tejinder"/>;

This is nothing but a JSX expression in which the Greeting is a component.
{6/7}
--> name is an attribute and "Tejinder" is the value of the attribute.

--> when React see this expression then it passes the props as an object.

--> For e.g -

props = {name: "Tejinder"}
{7/7}
--> Let us take an to see components , props and rendering.

See the snippet.
If you like this make sure to:

Follow me @tejinder_id for web development-related tweets.

Thank you so much for staying to the end of this thread.

• • •

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

Keep Current with Tejinder Sharma

Tejinder Sharma 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 @tejinder_id

May 7
⚡️ Let us make a Border bottom with a hover effect using HTML and CSS.

A Thread 🧵
1. First we will write "a" tag in HTML.

--> Next we will design it using basic properties of CSS like text decoration, color, font size, etc.

--> We used transform property to center it w.r.t our page. Image
2. Now we will use the pseudo-random class to make a border.

--> We will make it a block element so that it will start from the new line.

--> Initially we will set its width to 0 and height set to 4px;

--> There is no content because we will fill the entire height with color. Image
Read 6 tweets
May 5
⚡️ Day 79 ⚡️

⚡️ Let us discuss JSX and rendering in React.

⚡️ I tried my best to explain each term with an example.

A thread 🧵

#100daysofcode
1. what is React?

--> A JavaScript library for building user interfaces.

--> React will efficiently update and render(make) just the right components when your data changes. (we will see it in the last of this thread).

--> we will study more about React in our coming threads.
2. What is JSX?

--> const element = <h1>Hello, world!</h1>;

--> In the above line, we defined a const and assigned a value to it.

--> The value is neither a string nor an HTML.

--> Then what is it?, it is nothing but JSX.

--> JSX is very much used in React.
Read 11 tweets
May 4
⚡️ Day 78 ⚡️

⚡️ Let us discuss:-

1. Mutability and Immutability in JavaScript.

2. Avdavtages of Immutability.

A thread 🧵

#100daysofcode Image
1. What is Mutability:-

--> It is the property to mutate (change) the data by directly changing the data’s values.

--> see the code snippet to understand it. Image
2. What is Immutability:-

--> In this approach, original data remains the same.

--> we make the copy of the original data and if want to change anything then we change in the copy of the data, not on the original data

--> see the code snippet to understand it. Image
Read 6 tweets
Apr 29
⚡️ If you are learning tailwindcss or planning to learn it. Then you can refer to the resources in the thread so that you can learn more with practice.

A thread 🧵
⒈ To learn tailwind CSS:- Go to the official website where it has covered each topic with examples.

Link:- tailwindcss.com
2. Ready-made Tailwind CSS blocks.

link:- tailblocks.cc
Read 14 tweets
Apr 27
⚡️ Day 71 ⚡️

⚡️ Today I started working on my friend's website.

⚡️ Made the first section using HTML and Tailwindcss.

⚡️ This is not the complicated one.

⚡️ Let's discuss it.

⚡️ A small thread 🧵

#100DaysOfCode
⚡️ First we discuss the header section.

⚡️ For the background image, we used the background-image property with the linear gradient.

⚡️ See the snippets each class name is self-explanatory.
⚡️ Now we will design the other elements.

⚡️ For more study of a class name you can refer tailwind website.
Read 5 tweets
Mar 10
⭐️Day 41⭐️

⭐️Let us discuss how to make STEP using HTML and CSS?

⭐️We are going to use Flexbox, positions, and inline-flex properties.

#100DaysOfCode

A Thread 🧵
⭐️We will make one step and repeat the same procedure for the other 3 steps.

Let us first make an HTML structure.

We will design our "step" class using position relative.
⭐️Now we will make the straight line using the absolute position property.
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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(