The internet has permanently ruined my expectations

I saw this video on Reddit, and for some reason — I felt like I was about to witness one of the most outrageous fits from someone that received a wrong gift during this holiday season. For those that…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




A Crash Course Intro to React

Fundamentals of React

React is used for front-end web development, it’s what your user will see and interact with when they come to your website or web application. You might be thinking, “what makes React so special?”; there are several features that make React shine:

Let’s take a look at what a component would look like and how that would integrate into your app:

We’ll start off by create an Article component:

Sidebar: If we decided to just render this component, we’d have something like this rending on the DOM:

Next, we’ll create another component called Comment:

Now we can incorporate our components into a top-level parent component that we’ll call App:

Now that we have that all set up, we can see that both components render in the DOM!

Prop is short for property. Props allow us to pass values into our components and is passed down from a parent component to its child component so that it can access, and potentially change, a property that is defined in the parent component. Props can be anything, objects, like arrays and functions, strings, and so much more. Lets take a look at an example:

To start we’ll create some props that we want to pass down to our MovieCard component:

Now, we’ll pass those in to MovieCard:

Et voila! We have ourselves a MovieCard component with dynamic prop data:

A state in React is simply data that is changed within a component, unlike with a prop, state allows us a way to track and update information within a component without requiring updated information from its parent component. Let’s see an Example:

Let’s say we have a component that displays a number, every time the component is clicked we should increment that number by 1. If we track this number in state then our component can update without needing any props passed down!

As mentioned above, to change the data in a state, we need to use the ‘setState’ method at which point we can assign our state a new value!

I’ve included above the basics of React to get you started! I’ve tried to be as brief as possible, but the resources below go more in depth! Happy coding!

Add a comment

Related posts:

Feeling Down? Here Are 20 Products That Can Help Boost Your Mood Instantly

We talk a lot about ways to boost your mood because having a random bad day here and there or feeling a little extra stressed is a part of being human. But just because we all get bad days sometimes…

Want An Easy Fix For Your Eligibility Criteria For Home Loan For Salaried Person?

Having a home is the biggest asset that a person can own. Everyone dreams of owning a home. It’s the space where they can create happy memories with their family. However, buying a home is no easy…

How AI Search Engines are Transforming the Landscape of SEO

The world of search engines is rapidly evolving, and the advent of artificial intelligence (AI) is playing a significant role in this change. AI search engines are already starting to disrupt the…