Get data from an API in React

In this article, I’ll show how to make a request to an API to get data and then display it in a React component. This can be broken down into three steps: Here’s a working code example of how to do this: Note: Install the axios package with ‘npm install axios’. If you prefer to … Read more

React Router DOM error: ‘[Component] is not a Route component’

If you upgraded to React Router DOM v6, or if you are starting with v6 and you’re using code examples from before v6, then you’ll run into breaking changes. One such breaking change causes the following runtime error: Error: [Component] is not a <Route> component. All component children of <Routes> must be a <Route> or … Read more

Hello World with React

I’m going to show you how to create a Hello World web app with React. Note: I’m using React 18, which is the latest version at the time of this writing. 1 – Install VS Code VS Code is a really good IDE for developing React apps. So first things first, go download and install … Read more

JavaScript – Send requests with fetch()

The simplest way to send requests in JS is to use the fetch() API. Here’s an example that gets a stock quote from a web API and displays the results: You can wire this up to a button click (and have a div for displaying the results): Note: fetch() is supported in all major browsers … Read more