βš› What is React?

Let's explain! πŸ‘‡πŸ‘‡πŸ‘‡

#100DaysOfCode
#CodeNewbies
#DEVCommunity
#reactjs
React is a framework that makes it easier to create complex web pages. How does it do that?
Imagine you're developing a to-do app. Let's say you just need to display 4-5 tasks. Ignore functionality like adding, or marking tasks as complete.
If we were to just write some static HTML, the code would look something like this:
The tasks are included as part of an unordered list, or <ul>.

Each list item <li> contains the title of the task, the date it has been added and the the deadline. So you can see that each item is slightly complex.
Obviously, in real life, to-do lists aren't just hard-coded HTML. You will need to get the data from somewhere, like an array of JSON objects.

Like this:
We would then have to use Javascript in order to display the to-do items in exactly the same format as above.

The code would look something like this:
We can all agree that this looks ugly and nasty. Not what you had in mind when you needed some dynamic data for your website. And it gets worse with more complex pages.
What if we could build complex dynamic user interfaces, but instead of spaghetti JS, we used something close to HTML?

Enter βš› React!
React, as mentioned in its own documentation is "a JavaScript library for building user interfaces". And it's an accurate statement. It makes it a lot easier to create complex user interfaces.
But how does it work? How can React make our ugly code above into something clearer and more comprehensive?
In React we can do this:
"Hang on a minute", I hear you say. "Did we just... write simple HTML within Javascript? And then added additional Javascript ONLY when we need it?"

Well, yes we did!
We defined a Javascript function and in that, we just wrote some HTML. And when we needed some more complex functionality, like looping through our to-do list, we just embedded some simple Javascript.

Incredible isn't it?

That's the power of React!
This is how React makes developing complex user interfaces so simple. But that's not all...
React also enables you to tidy up your code. How?

It enables you to break down your page's code into smaller, more manageable chunks!
Let's say now you're building a portfolio website. You need to include a header, a list of your skills, and a list for your projects. In React, it would look something this:
In React, you can store each of these sections in their own file.

For example, the skills section can be its own file, and it would look like this:
If all of our sections have their own files, we can then import them into our website like this:
Look how clean our code has become!

Each of these sections in their own files is what in React, we call "components".

And even greater, is that we can also separate our CSS, making it much more manageable!
So how do you get started?

First, you need NodeJS, which you can download here nodejs.org
Next, you need a package called "create-react-app" which you can get with this command:

npm install -g create-react-app
Finally, you can create your first React app with this command:

create-react-app my-app
Now point your terminal inside your app see how your app looks:

cd my-app
npm start
That's it! Now that you have a basic knowledge of React, you can explore the official docs!

Have fun!

reactjs.org/docs/getting-s…

β€’ β€’ β€’

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

Keep Current with Savvas Stephanides

Savvas Stephanides 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 @SavvasStephnds

15 Oct
What is Docker? Let's explain! πŸ‹πŸ³

(Thread) πŸ§΅πŸ‘‡

#100DaysOfCode
#CodeNewbies
#docker
πŸ”ŒBefore I begin: This thread is also available in a more convenient and more accessible format at my new project "Let's Explain" (where you'll find all my other "let's explain" threads as well):

β–Ά letsexplain.netlify.app/docker
So you've just built a project. Let's say it's a to-do app. There are plenty of things involved:

- front-end
- back-end
- database...
Read 20 tweets
1 Oct
What is async/await in Javascript? Let's explain

(Thread) πŸ‘‡πŸ§΅

#100DaysOfCode
#CodeNewbies
We've already talked about Promises in a previous thread. Read it if you haven't already. This thread will be a continuation of that thread so please see that first:

So as we mentioned before, Promises are a way of telling Javascript, "go fetch some data but I'm not going to sit and wait because my browser would freeze. When you DO get a response eventually, do THIS with the data".
Read 20 tweets
26 Sep
β™ΏοΈπŸ¦Ύ ACCESSIBILITY QUIZ!

10 questions. Have fun!

#100DaysOfCode #a11y #CodeNewbie

🧡 πŸ‘‡
QUESTION 1:

The standards for web accessibility are called:

A. Accessible Web Initiative
B. Web Accessibility Working Group
C. Web Content Accessibility Guidelines
ANSWER: C
Read 22 tweets
22 Sep
❌ β€œI built a to-do app with React”

βœ… β€œI have built an app that has helped people stay on top of their day-to-day tasks and stay organised using my React skills”

πŸ‘‰ It’s about the impact you have on people, not your skill set
❌"I built a weather app with Vue"

βœ… "Enabled users to plan their day by building an app which provides clear and convenient hourly weather forecasts. Make flexible, expandable and fast by using the Vue framework to build the app"
❌ "Created a website for a restaurant"

βœ… "Enabled a local restaurant to quickly and conveniently communicate with their customers about their menu options and latest offers by creating a fast website for their establishment, thus increasing their profits by 15%"
Read 4 tweets
21 Sep
What is "this" in Javascript? Let's explain:

Thread πŸ§΅πŸ‘‡

#100DaysOfCode #CodeNewbies
First off, a note: I was planning on create a thread like this for ages, but I have been putting it off for one simple reason: just like a lot of people, I too didn't quite get the "this" keyword. It still baffles me a bit but hopefully this basic walkthrough will make sense.
"this" is basically a label. It's a label you put on a function to show who it belongs to. Sort of like putting a label on your food at work saying "THIS SANDWICH BELONGS TO <your name>"
Read 15 tweets
1 Sep
The problem with the "typewriter effect" on your website and how to fix it.

(Thread) πŸ§΅πŸ‘‡

#100DaysOfCode #CodeNewbie #accessibility
So you want to show off your portfolio website and you want to add some fancy graphics to show off your Javascript skills. What better way than by adding a fancy "typewriter effect" to show the world your multi-faceted personality?
It's nice, sure! But there's a problem. And it has to do with accessibility.

Simply put, blind people visiting your website with screen readers, just can't see what the hell you've written on that section.
Read 10 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!