Photo by Emile Perron on Unsplash

I don’t want to lose too much time explaining the concept of Context; there are simply too many great explanations of it out there like here, here, here, here, here, and here. But I can’t just throw some code at you so here we go: Context allows you to access data anywhere and avoid excessive prop drilling in your app. The React docs do a great job summarizing the concept:

Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language.

It should not…

I don’t write about politics and I don’t really write letters. I wrote one letter, about a year ago, to convince a friend to vote in this election (he had never voted in ANY election…and this year he is!) but that was pretty much it. As 2020 has progressed and the consequences of electing Donald Trump has weighed on the nation, I could not help but write one more. If you’re reading this, this letter probably isn’t “for you”…it’s actually more for the Trumpers in your life. …

Functional components are the bread-and-butter of any React application, especially with the addition and expansion of React Hooks. This post breaks down a simple functional component (Version #1) and then shows four additional ways it could be written. Enjoy:

Version #1: ES5 and Props Object

This first version is very simple. It’s a simple function called `Button` that takes an argument, props.

Version #2: ES6 and Props Object

Version #3: ES6 and In-Function Destructured Props

Version #4: ES6 and Destructured Props

Version #5: ES6 and Export Default Anonymous Function

Colin McNamara

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store