Tutorials Page 12
React usePrevious Hook
Hooks are essential for the functional component pattern in React. One frequent logic comparison with
class
components was comparing a previousprop
value with a currentprop
value via lifecycle methods. So what's an easy pattern for duplicating previous value comparisons in functional components?TheuseRef
and...Set a Default Node Version with nvm
As I've shown you in the past,
nvm
an excellent utility for switching between Node.js versions. Whether your host machine or CI, building and testing your apps on different Node versions is a necessity. I've recently found a fewnvm
commands that I found really...onInput Event
Coding HTML forms has been painful my entire career. Form controls look different between operating systems and browsers, coding client side and server side validation is a nightmare, and inevitably you forget something somewhere along the line. Some behaviors don't act the way you'd...
Dark Mode in One Line of Code!
Dark mode has seemingly become the desired visual mode for websites and mobile apps alike. Dark mode is easier on the eyes, especially for those like me who like to burn the midnight oil by coding and reading tutorials. Unfortunately not all websites offer...
Fix Seeing “0” in Your JSX Code
The early days of the web felt like the wild west when it came to coding practices -- just make it work. Then we became enlightened to better practices, separating HTML from CSS and JavaScript. Then came React and JSX, where we combine JavaScript, HTML...
How to Upload a File via SSH and Command Line
My preference for daily work is usually GUI applications, like Visual Studio Code for text editing and Cyberduck for remote file server management. I'm also a huge fan of automation, so I do try to learn the command line equivalents of UI functions. My...
Always Show Arrows for Number Input
While I enjoy small details that make user interfaces more elegant, I also believe that less is more, especially when it comes to native behavior. One native behavior I dislike is that
<input type="number" />
elements only show the increment and decrement arrows when theinput
...Gather Feedback Using the Amazing UserWell
Most websites and mobile apps collect all sorts of data to try to gain insights into what users are doing, not doing, and to gain insight into what users may want. Those metrics are useful but there's a more valuable way to get information: direct...
JavaScript Numeric Separators
Writing good code is important -- writing code that's easily human readable is a next level skill. It's not often that APIs are introduced whose seemingly only useful function is making code more readable, but let me introduce you to JavaScript numeric separators: an API that...
How to Restart a BAT file on Windows at an Interval
I recently wrote a
.bat
script on Windows to mine Ethereum when I'm not using my gaming PC to frag noobs. I have a friend who also tries to mine cryptocurrencies but their machines have AMD processors; every once in a while, the processor...