JavaScript fundamentals before learning React.

Some people believe that you need to be a JavaScript master before starting learning React, and that couldn't be further from the truth.

You should know some fundamentals, and I want to tell you exactly which ones.

Let's begin 🧵 JavaScript fundamentals before learning React.
let and const.

This is the ES6 way of assigning variables, it replaces "var".

"let" is for variables that are gonna be reassigned in the future.

"const" is for variables that are not gonna change, you define them and you use them, but they have a "constant" value.
imports and exports.

A big part of React is reusability. You create a component (like a button), export it, and then import it on your other components without having to write it out again. /* components/Button.js */ const Button = () => {   return <
Functions.

Arrow functions would be better, but if you know how to write normal functions, this also works.

Let's see our Button component with normal functions vs arrow functions, they are really similar!

Arrow functions have an implicit return, so they can also be shortened /* Functional component */ export default function Button()
Template literals.

This is an easy way to concatenate strings. You use the backtick ` for them.

Instead of having to do:

"Hello, my name is " + name + ", nice to meet you!"

You do:

`Hello, my name is ${name}, nice to meet you!`

A lot easier, isn't it?
map and filter.

These are the two most important methods in React.

map() returns a new array with the results of the passed function. This is essential to render data of an array.

filter() returns a new array with all the elements that returned true from the passed function. const MyComponent = () => {   const friends = [     { name:
Array destructuring.

This unpacks values from arrays into different variables.

This is important to know because it's used in useState, one of the first things you will learn in React. const intro = ['Hello', 'I', 'am', 'Nacho'];  const [greetin
Object destructuring

Similar to array destructuring, this lets us extract properties into a variable named with the property name.

It's especially useful for functions. const friend = { name: 'Nacho', age: 25 };  // Without objec
Conditional ternary operator.

This is a way of making a single line if statement.

This can be used to decide what to render on a page depending on a condition.

First, the condition, then '?', what to render if the condition is true, a ':' and what to render if false. const MyComponent = (friend) => {   return (     <div>{frien
Conditional rendering.

What if we don't want to show anything if the condition is false?

We can do

condition ? 'something' : null

Or we can also do

condition && 'something'

This will produce the same result but its much cleaner.
These are the fundamentals you need to know before learning React.

Don't try to learn everything in JavaScript before trying it.

And if you feel ready to build your first app, I have a tutorial ready just for you!

• • •

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

Keep Current with Nacho Iacovino ⚡

Nacho Iacovino ⚡ 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 @nachoiacovino

8 Feb
Let's build your first App in React.

React is the most popular JavaScript library to build websites nowadays.

If you have never tried it, I want to show you today how to create a very basic counter app that will teach you the fundamentals.

Let's begin! 🧵
First step!

Having Node.js installed. If you haven't, follow this link and download and install the recommended version.

nodejs.org/en/
Now we are gonna open a terminal (cmd, Bash, PowerShell...) in the folder that we want to create our project.

Write this command:

npx create-react-app my-first-app

npx will download CRA latest version and delete it when it's done. "my-first-app" is the name of our app.
Read 15 tweets
23 Dec 20
Let's talk about Git.⚡

Git is the only thing that's it's common in our field. 99% of developers use it.

So you should learn it. At least the basics. And use it. On all your projects.

Let's start the thread.🧵

#100DaysOfCode #git #github #javascript #CodeNewbie #js What is Git? Let's learn th...
⭐ What is Git?

Git is a version-control system for tracking changes.

This allows you to save different versions of your projects and come back to them when necessary.

This also allows you to work in a team in a much better, organized way. ⬇
⭐ First steps.

On your project, your first command should be:

git init

This will initialize a new repository, this repository is a hidden folder called .git that tracks the changes made to files in your project and builds a history over time. ⬇
Read 11 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!