How to Load Data from a REST API with React Hooks

With this week’s release of React 16.8, Hooks were finally released into the wild. They allow us doing a lot of stuff that wasn’t possible until now. For example, loading data into the state of a functional component. But let’s have a closer look.

Continue reading How to Load Data from a REST API with React Hooks

How to Call a REST API from a React Component

At some point in your journey of learning React, you’ll get to the point where you want a component to consume an API. Or maybe you want to connect your app to a REST backend, you name it. After all, you want that flippin’ data from that server in your app.

But how do you get the data from an API or your backend into your component?

Continue reading How to Call a REST API from a React Component

How to fix the Whitescreen After a Static Deployment with create-react-app

It’s one of the most annoying situations after deploying a static React app: After all that work, you finally deployed your app for production. But as you visit the site – instead of your freshly deployed app – you see … nothing.

A blank, white, screen. Continue reading How to fix the Whitescreen After a Static Deployment with create-react-app

How to fix BrowserRouter for React Apps on Apache

While learning React, most people develop and test their apps locally. I mean … they’re just demo apps for learning purposes right? Nobody wants to see stuff like that, so why even think of deploying the apps somewhere?

But then comes the day where you try to deploy a React App to a web server, so you could show it to the people out there: “Look! I made this!”. And that’s how it was for me too. Continue reading How to fix BrowserRouter for React Apps on Apache

Is there a way to host a React app without a NodeJS Server?

So you built your first React app and now it’s time to get it out in the world. But where do you host a React app?

Until now, you probably ran your app with npm start which spins up a development server for you to debug and test your app. But that won’t work in production. Continue reading Is there a way to host a React app without a NodeJS Server?

Sync up multiple Promises to a single result set with Promise.all

Did you ever try to use data from multiple Promises but could not figure out how to sync up the requests to return a single result or Promise?

For example: A http request (e.g. using fetch) returns a single Promise that is executed asynchronously. If you would just execute a bunch of requests, there is no chance to get all responses into one array just by calling them after each other. Continue reading Sync up multiple Promises to a single result set with Promise.all

How to dynamically add CSS Classes to React Elements using State

If you’re just starting out with React, you might soon get to the point where you want to dynamically change the styling of some React Elements – e.g. at the click of a button. In this post we have a closer look at this concept.  Continue reading How to dynamically add CSS Classes to React Elements using State

3 Quick Wins to Test Your Presentational React Components with Jest

Did you ever ask yourself, if it makes sense to test presentational components, or if it’s just too time consuming? Good news, you’re not alone! That’s why I put together three ways to create useful Jest tests for your presentational components without spending too much time.

Continue reading 3 Quick Wins to Test Your Presentational React Components with Jest