A Really Pesky Bug in React

I am going to document this bug because I believe it’s happened before, and it really took me quite a while the previous time to debug also. I’ll call this bug: can’t get past the first render. It involves inconsistencies in accessing props(i.e. data) from child components, causing the page to break. Yet, the description is really not helpful: TypeError: rowData is undefined react. The root cause of the bug lies in how React handles the logical flow of ReactHooks. For future me reading this, I’ll briefly detail the component structure: ...

August 25, 2021 · 3 min · Lei

Getting Latest Date From Array of Objects in Javascript

Let’s say I have an array of objects, like so: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 let trades = [ { id: 1, date: "2019-04-23T18:25:43.511Z", asset: "BTC", orderType: "Limit Buy", platform: "Coinhako", price: 46580, price_denom: "USD", nominal_price: 32313 , amt: 0.003, value: 139.74, value_denom: "USD", fees: 4, fees_denom: "USD", comments: "good buy" }, { id: 2, date: "2019-05-23T18:25:43.511Z", asset: "BTC", orderType: "Limit Buy", platform: "Gemini", price: 38000, price_denom: "USD", nominal_price: 32313, amt: 0.02, value: 760, value_denom: "USD", fees: 14, fees_denom: "USD", comments: "not bad buy" }, { id: 3, date: "2019-05-23T18:25:43.511Z", asset: "Alibaba", orderType: "Limit Buy", platform: "SC", price: 196, price_denom: "HKD", nominal_price: 34.07, amt: 100, value: 19600, value_denom: "HKD", fees: 128, fees_denom: "HKD", comments: "bad buy" } ] I want to get the latest date. ...

August 25, 2021 · 2 min · Lei

Setting Up the Frontend for It to Be Making Requests to the Server

Assuming that you’ve not set up anything. Step 1: Installing Axios npm install axios Step 2: Importing and sending request 1 2 3 4 5 6 7 import axios from 'axios' axios .get('http://localhost:3001/notes') .then(response => { const notes = response.data console.log(notes) }) For most part, that will suffice. However, you might want to call the data via an effect hook. ...

August 25, 2021 · 1 min · Lei

Steps for Setting Up the Backend During Development

Alrighttttt I am about to embark on some backend development for my Streams app. This document acts as a kind of guide for future development processes, as the exact processes are rather rusty in my mind. I am starting out from completely no backend on my simple React app, with a couple of frontend components. I think the first thing I need to do is to set up an express server. ...

August 25, 2021 · 3 min · Lei

Streams App Documentation

Component Tree: App LeftNav NavigationMenu NavHeader NavSections : section {section}–>|NavSection 1 {section}–>|NavSection 2 {section}–>|NavSection 3 {section.menuItems} (an array of objects)–>MenuItems | Maps over: MenuItem

August 24, 2021 · 1 min · Lei

Notes on Flexbox

Flexboxes are getting more and more important in designing responsive web pages. In my case, I need it to help design my left navigation bar for my app. Here are some notes taken from the video below for reference. Containers and items without flex ...

August 24, 2021 · 4 min · Lei

Mondodb Database Design

So whilst I was trying to design the database for my investment tracking app, I stumbled upon the question of what are the differences between traditional database designs and NOSQL, and what’s the most optimal way to design the NoSQL database for best performance. After a quick look around, I discovered that there are no special things you need to do to design NoSQL schemas, apart from simply treating it like you would store info in a python dictionary: through the JSON structure. ...

August 23, 2021 · 1 min · Lei

Css Variables

Whilst I was scrolling through Reddit, I noticed this line in the css file for the super slick input field above: 1 2 3 4 5 6 7 :root { --main-blue: #90caf9; --main-white: #fff; --main-grey: rgba(255, 255, 255, 0.23); --main-dark-grey: #121212; --main-ease: cubic-bezier(.65,.05,.36,1); } And so I googled what on earth is the :root selector, and what on earth are the –main-blue syntax. What I learned was incredibly useful. ...

August 23, 2021 · 2 min · Lei

First Google Analytics Data Drilldown

After having set up Google Analystics on Friday, I am about to have some fun analyzing the data. Navigating through Google Analytics isn’t the most intuitive. Well - it’s easy enough, but it still takes some time for me to figure how what does what on the website. The reports page really doesn’t give me much insights about user behavior on my site. To get real insights, I had to go to explore page. There, I could set up a new exploration (much like cards in Metabase), where I could get more granular detail on my data. ...

August 22, 2021 · 2 min · Lei

Google Analytics Realtime

Google Analytics Real time is pretty mind blowing. I really don’t recall the set up to be so easy back in 2013, when I made my first website and began implementing tracking. After a mere 5 minutes of adding the GA code to my site, the data began showing up on the platform. And the real magic was when I clicked on view user snapshot. It took me to this screen, where there was really tonnes of information about how a random user interacted with my site. ...

August 20, 2021 · 3 min · Lei