dev notesjuhana jauhiainen
Writing about web development, React, Python, and the tools I use
Use useReducer to manage complex state
useReducer is a React Hook which helps you manage complex state with a simple API. The hook takes a reducer function and the initial state as parameters. You can also pass in an optional argument which can be a function for lazy initialization of the state.
Read more ⟶
Manage React state with the useContext hook
React projects have many options for managing state. While libraries like redux and mobx are a popular choice, React also has it's own API for managing state. The Context API is useful when you have state which is accessed in multiple places in your app and you want to avoid prop drilling...
Read more ⟶
Make custom marker displaying users location and direction with react-native-maps on iOS
If you want to display the current GPS location with your own custom graphics in React Native Maps, you need to create a custom Marker. This is done fairly easily, since the Marker component accepts a View as child.
Read more ⟶
What is React Strict Mode?
React Strict Mode is a tool, which comes with React, for detecting possible issues and problems in your application. Currently (Sept. 2020) Strict Mode detects if you have unsafe lifecycle methods, usage of legacy string ref API, usage of findDOMNode, detecting unexpected side effects or detecting usage of legacy context API.
Read more ⟶
Access DOM element in a child component in React
Sometimes we need access a DOM element which is contained by another React component. If we try to just use ref and pass it to the child component, we get an error. This is because ref is a reserved prop name so you can't pass it to a child component. Instead we can use forwardRef when defining the child component.
Read more ⟶
Customize Django admin with list_display property
One of the great "batteries included" features Django has, is the automatically generated admin panel. It provides a simple UI for creating, editing and deleting data defined with the Django ORM. In this article we are going to enable the admin user interface for a simple model and customize it from a simple list view to a more user friendly table like interface.
Read more ⟶
Using namedtuple to create simple data objects in Python
Python standard library has a handy collection factory function called namedtuple, which can be used to assign names for each position in a tuple. Named tuples behave otherwise like a normal tuples but each element has a name which can be used for retrieving the value just like with class objects.
Read more ⟶
Introduction to relative CSS units
With CSS you can use absolute units like the familiar px, pt or relative units like em and rem . Absolute units are quite simple to use and rarely cause confusion. Relative units however can twist your brain if your not familiar with how they work.
Read more ⟶
Create a React Hook to show browser online status
React Hooks are a way of adding logic to your functional components in an simple and elegant way. In addition to the standard hooks like useState or useEffect you can also create your own hooks if find you need the same logic in multiple components.
Read more ⟶
Small projects for learning the Rust programming language
Inspired by some of Jon Gjensets Rust streams and videos I decided to start learning Rust (again!). I've previously read part of the Rust book but never started any projects with it so I didn't retain much of it.
Read more ⟶