Fetching data for a website is a common use case so it's a good example for exploring the different ways we can reuse common functionality in a React app, and this article covers using Higher Order Components.
When returning JSX from a React component you may wish to return output depending on the condition of the value of some variable.
Here's how you can conditionally render JSX inline in a React component...
An IIFE stands for immediately invoked function expression. I’ve also heard the term self invoked anonymous function (SIAF), but IIFE encompasses the pattern with a named function too.
Here’s the code for those that want a quick copy-and-go, but we’ll run through it underneath for those who want to understand the syntax 🍻.
I'm using Prism.js to style the code blocks on Frendly, but when I was setting it up I couldn't find official docs for adding Prism.js to a Next.js site (which Frendly is built with). Here's how I managed to get things working.
Much like myself and my shattered family relations, React doesn’t like siblings. More specifically, it doesn’t allow siblings in a return function while rendering.
As of React v16.2.0 you can use React.Fragment to wrap the sibling elements.
This post is currently being written! It's a placeholder while Frendly is in being designed. More coming soon...