dev notesjuhana jauhiainen

Writing about web development, React, Python, and the tools I use

Making API calls in React useEffect


useEffect is a hook added in React 16.8. It allows you to perform side effects in function components. This means you can update things outside of React based on your props and state. Fetching data when the component state changes, changing the page <title> or connecting to a WebSocket server are all examples of side effects that can be done with useEffect.
Read more ⟶

Dark mode using prefers-color-scheme rule and CSS variables


In this article I'll show you how to implement dark mode in your blog or site using CSS variables and how the toggle it automatically based on the users preferred color scheme.
Read more ⟶

How to loop over a JavaScript object


There's a few ways to loop over a object in JavaScript. Let's look at a couple of them. Let's say we have a object like this
Read more ⟶

The very basics of React Hooks


Hooks are an React API that were introduced in React 16.8 a little more than a year ago (february 2019). They let you use state in your React components without writing classes.
Read more ⟶

Memoization in Python


Memoization is a optimization technique frequently used in functional programming. It means storing the result of a computationally intensive function call and returing the cached result when the function is called with the same arguments.
Read more ⟶

Python class and instance variables


Confusing class variables and instance variables in Python is a pretty common mistake. Or.. atleast I've made it more than once. Python doesn't use static keyword but instead the location the variables are defined in to differentiate between the two which will seem pretty foreign to people coming from other object oriented languages.
Read more ⟶