Nathan Smith
  • Projects
  • About
  • Contact
usePrefersDarkTheme: a theming hook for React

July 24, 2020, 9:01 PM

React

Every site needs a dark theme, including this one. Having a dark theme is easy, but if an app or site's theme doesn't follow the system theme it can lead to blinding the user with a white background until they find the toggle. This hook (and some related code to ...

HooksHow-ToReact
usePrismjs: A prismjs hook for CRA & React

May 20, 2020, 9:14 PM

React

featured

What is it? Prismjs is a powerful little javascript to add syntax highlighting to <pre> and <code> blocks, but it hasn't kept up with a JavaScript framework-using, module-bundling world. There aren't many docs around how to use it with the npm package, and most want you to use a babel ...

Why functional components are the future of React (but hooks are dangerous)

June 25, 2019, 1:21 AM

React

featured

I was skeptical. Why would I ever write a functional component instead of a class component? Now, I've seen the light, but also the alluring danger of hooks.