Tejinder Sharma Profile picture
May 5 11 tweets 3 min read
⚡️ 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.
2.1 JSX continue

--> JSX is called "syntax extension to JavaScript".

--> We used JSX because it includes markup and JavaScript in the same expression.

--> If we want to use JavaScript expression then we will use it inside curly braces(e.g {name} ).
2.2 JSX examples:-

1. const name = 'Tejinder';
2. const element = <h1>Hello, {name}</h1>;

--> First expression in JavaScript Expression.

--> Second expression is JSX expression, if we want to use 1st expression in the second expression then we will use curly braces.
3 What is rendering?

--> Like in JavaScript there is DOM and we display and control elements using DOM.

--> Similarly React has its own elements and DOM.

--> Render means to put an element inside the root element.

See the code snippet
3.1 Updating the rendered Element:-

Let us First create a root element:-

const root = ReactDOM.createRoot(document.getElementById('root'));
3.4 Now we will create JSX with one "div" and two "h" tags.

See the snippet.

--> new Date().toLocaleTimeString(); this is nothing but JavaScript.
3.5 Now we will make a function and wrap JSX in this function.

see the snippet.

--> we also include the root. render(element) in function so that time will update at the given interval as set by

setInterval(tick, 1000);
3.6
--> In the last step we will call the function every 1sec using setInterval(tick, 1000);

--> Now if we inspect the h2 heading we come to know that only time is changing not the whole element.

--> It makes the process faster to check the bug if any occur.
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 6
⚡️ Day 80 ⚡️

⚡️ Let us discuss Components and Props in React.

⚡️ We will discuss each with examples.

A thread 🧵

#100DaysOfCode Image
{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).
Read 9 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!

:(