mergeProps is available and allows you to further control the props that the component receives. It’s not useful all of the time, but when it is it can enable you to adapt to any component structure, reduce component complexity, and improve performance.
When working with tools like React and Redux, they discourage making direct edits to the state. Why is this? It’s more prone to errors. The less you mutate your data, the better, and the easier it will be to reason about your code. The concept of not changing values is known as immutability. It’s one […]
In earlier versions of React, you were required to use classes if you needed to manage state. Now with hooks that isn’t the case. Let’s explore the options
You can write React components in two ways: As a function, or as a class. It can be confusing to understand which you should use and why. For devs brand new to React, they may not understand the history and recent changes between the two. If you ask online, everyone says to use function components. However, almost every tutorial, even the official documentation, favors classes. Why the divide?
The less you mutate your data, the better, and the easier it will be to reason about your code. The concept of not changing values is known as immutability. Handling immutability with objects can be tricky. Here are some examples for handling various use cases. Add or replace an element to an object Similar to adding […]
Part of the class components to function components series. In earlier versions of React, one of the biggest downsides to using function components over class components was that you could not use life cycle methods. What if you need to do something when your component mounts, like fetch some data or set some initial state? […]
There are situations where you do want to share state between multiple components, and you may not want to bring Redux into your architecture. In this tutorial, you’ll learn how to create your own mini-state management system.
If you are using class components, but want to use hooks, you can’t do so directly. One strategy for adding them is to use adapter components. Another strategy is to use higher-order components to pass along data from hooks as props. Here’s how