A Look at Functional vs Class Components with React Hooks

Choose your character!

Nope.

Thanks for reading!

.

.

Oh I have to explain myself? Alright fine…

Quick Background

So when I first learned React, you had to make a choice when creating a component. You could create the component as a simple function that returns some JSX (hence its called a Functional Component), or you could declare the component as a React.Component class inherited from the React library (hence why it’s called a Class Component).

The Functional Component was generally used for simpler components that would just display info passed into it, whereas a Class Component was what you would use when you needed…


An introduction to hash maps, hashing functions, collisions, and everything else you may have heard of but not quite looked into yet.

Intro to Hash Maps

A Hash Map (sometimes called a Hash Table) is a Data Structure commonly used to provide a faster way to retrieve data at the cost of using more memory.

Let’s say I had a massive array of data and I wanted to find a value within it. If I now the exact index of that piece of data then I can look it up directly, but if I only know the value I’m searching for I would potential have to look at each index of the array until I find the value.

A Hash Map provides that index style lookup…


I was recently asked in a Technical Interview to solve the following problem:

“Write a function to find the smallest non-negative integer that is not present in a given array of non-negative, distinct integers”

I thought this was an excellent question, because at first it seems very simple, but as you dig deeper into it, there will almost certainly be many ways to improve the initial solution you come up with. Let’s dive into it now.

Brute Force

When I’m doing these kind of questions (especially in an interview setting when the person interviewing you is watching you code, and there is…


How similar functions with the same Big O Notation can have very different runtimes in the real world.

I was inspired to write this blog when I was practicing some problems on LeetCode earlier today.

If you’re familiar with LeetCode you know that the general format is you’re given some problem to solve and you not only have to write code that solves the problem correctly (and for all edge cases), but it also has to be able to run in a certain amount of time in order to be accepted. A solution that may work well for an input size of 10, could perform horribly slow if that input size is increased to 10,000.

The Setup

If you’re not…


And how to implement them in JavaScript

A heap is a specialized version of a Binary Tree

Introduction

So what is a heap? A heap is just a very specialized version of a binary tree data structure. Remember, that the main characteristic of a binary tree is that each node has AT MOST 2 children. Therefore every level you move down the tree the number of nodes doubles.

A heap, takes this definition one step further in that in addition to each node only having 2 children, each parent node also must be greater than (Max Heap) or less than (Min Heap) each of its 2 children. …


Introduction

This one’s a little specific. I recently built a project that required a Google Firestore backend and a React Frontend. The catch was the React App had to use class components in order to store state, instead of functional components with React Hooks.

If you are looking to use Google Firebase with a Realtime database, or looking to add Firestore to your React app and use React Hooks, there are tons of different tutorials out there, but I couldn’t find a tutorial for setting up my specific configuration, so I wrote one myself!

Setting up Firestore

This tutorial assumes you’re already familiar with…


Recently I was working on an app thats purpose was to log a bunch of different users git activity for a certain development server.

The backend of this project was a Rails API with multiple endpoints. Each endpoint required the JSON object returned to be formatted in a very specific way, and required some custom behavior thats not inherently included in the RESTful API flow.

I figured this would be the perfect opportunity for a crash course on how to use Serializers in Ruby, and how to write your own custom methods within them to return whatever you want.

What is a Serializer?

In…


For people who understand LLs in theory but have always wondered what the practical use of one is

Featuring the infamous 7 Line #LGM

If you have never heard of the term “Linked List” before here is a pretty good introduction on what they are. Assuming you have heard of them, and understand what they are conceptually, I’m here today to give some real life use cases to help you better understand why they’re useful.

Linked Lists for Navigation

I’m just old enough to remember back in the day when my family would go on a long drive and my mom would pull out a paper map in order to figure out how to navigate to our end destination.

Then an amazing innovation called MapQuest came along. You…


And Building Better APIs

What is GraphQL?

GraphQL is a query language (that’s what the QL stands for) developed by Facebook that provides us with a more efficient way to design, create, and access APIs.

It aims to improve upon the conventional API request process by allowing you to configure the structure and content of the data you ask for when making a request.

The general pattern is:

  1. Describe your data
  2. Ask for what you want
  3. Get predictable results back

Before GraphQL

Prior to GraphQL the standard was to build REST APIs which all follow a strict guideline for making your API requests. …


Featuring one of the best written scenes in TV history, the infamous “Middle-Out” Scene in Silicon Valley

If you’re a Jr. Developer from a non-CS background (maybe you completed a boot camp like myself or maybe you’re self taught) there’s a good chance you have asked yourself something like “Why do I need to learn what a Binary Search Tree is? I just want to design websites!” I definitely had this thought and even rebelled against the idea of learning data structures at first.

But here’s the issue. Once I started applying to full-time jobs or even internships at companies I liked, they all began sending me DSA heavy coding challenges.

So, begrudgingly I began the long…

Sean LaFlam

NYC based SWE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store