Month: September 2021

Man making fire on lake beach in forest.

How to Group State and Pass it Down to Children with React Hooks

Sometimes we have a React component that needs to pass many state values to its parent. Sometimes we even have grandchildren or props several generations deep that need to set state to their grandparent. See this example: Instead of passing all of that state as props to the child component, we can actually just save …

How to Group State and Pass it Down to Children with React Hooks Read More »

Silhouette of girl on purple and red sunset.

What are the Different Parts of HTML Text Input Elements For (in React and normal HTML)?

The HTML “text” input name For a text input, the name is part of the data sent to the server when the form is submitted. The name is paired with the input’s value, and these are sent to the server in the form name=Chris (if your input value was “Chris”). value The value of an …

What are the Different Parts of HTML Text Input Elements For (in React and normal HTML)? Read More »

How to Add Functions (including useState) to TypeScript Interfaces

I was having trouble finding out how to add functions to TypeScript interfaces. When I finally found out how I decided to write this. I’ll show the format immediatly below: We can see that to create a type for a function, we need to use the format functionName(nameForArgument: [argument type]): [type] . We need to …

How to Add Functions (including useState) to TypeScript Interfaces Read More »

How to avoid the JavaScript error “cannot read property ___ of undefined” without nesting logical AND (&&)

If we’re working with pulling data from APIs in JavaScript and React we may encounter the error “cannot read property [property name] of undefined. This occurs when we try to read a value from a nested object, but the object’s parent object has returned undefined: We are trying to pull data that we think should …

How to avoid the JavaScript error “cannot read property ___ of undefined” without nesting logical AND (&&) Read More »