If you’re a React engineer and you haven’t been living on the moon for the past nine months, chances are you’ve heard about React Hooks. The TL;DR is that before Hooks, class components were the only components that could track
state and make requests to an API. Hooks are functions that enable us to use
state and other React features in functional components. In this post, I’m going to walk you through four of the major Hooks —
useReducer — , all while refactoring the PhotoFinder app I built to go along with my 2018 post…
Responsive design got you down? Tired of guessing about Flexbox properties? Follow these simple steps and you’ll never have to copy and paste Flexbox code again.
Flexbox is an effective and easy-to-use CSS module for styling HTML elements inside of a parent so that they respond to changes in browser size. This responsiveness is accomplished by setting a variety of properties on both the parent (known as the flex container) and the children (known as the flex items). …
When it comes to operating on arrays,
.slice() are two incredibly useful methods to have in your toolkit. It’s not always easy, though, to remember which is which. I’ve put together this crash course on the ins-and-outs of each so that you can start splicing and slicing with confidence. I’ve also included two solutions to the common chunking algorithm: one makes use of
.splice(), and the other makes use of
.splice() method is a destructive array method, which means it modifies the array on which it is called (disclaimer: destructive methods can be risky, especially…
So, you’ve decided to learn React.js. Congratulations! This guide is intended to help you in your quest to understand four fundamental aspects of this incredibly powerful library. We will be building a very simple React app along the way that allows a user to enter a search term and retrieve a list of photographs that match this term from the Unsplash API. Let’s dive in.
Components are the building blocks of every React application. A component can be used on its own, or it can be combined with other components to create even larger components. Crucially, components are dynamic: they…
We’ve created a class Dog with three properties and two methods, one of which is
tellUsAboutYourSelf(). We’ve also created a new instance of Dog, which is saved into the variable
fido. Pretty straightforward. Now, let’s create another class and instantiate a new instance:
We’ve created a Cat object with the same properties as our Dog object, but our instance of Cat, which is saved into the variable
sparkles, isn’t able to tell us about itself. We could refactor our code so that…
You know the old saying: Everything in Ruby is an Object. But what does that mean? Where do these Objects come from, and why do they behave the way they do?
Objects come from classes, which you can think of as the blueprints for individual objects — they define the behavior of each and every instance of that particular class. But in order to fully understand the Object-Oriented nature of the Ruby language, it’s essential that you understand object hierarchy: namely, that every instance of a particular class inherits properties and behaviors from its ancestors. …
I just completed my second week of the Software Engineering Immersive at Flatiron School, and I’m going to unpack the difference between .sort and .sort_by in Ruby. I first ran into .sort_by when working on the final lab in the pre-work for my program. The lab was called “Alphabetize in Esperanto,” referring to the international auxiliary language known as Esperanto. The challenge? To write a method that accepts an array of strings and sorts them alphabetically according to the Esperanto alphabet. I solved the lab using .sort_by, but even so, I was still unsure of how .sort_by works “under the…