javascript

Configuring NGINX to work with React Router

· Reading time: ~1 minute(s) (168 words) programming javascript nginx tech

When using the `BrowserRouter` that's provided by React Router, you'll find that if you're navigating within the site to the various URLs, they will work. However if you bookmarked one of those URLs, or refreshed the browser on a URL, it will return a 404. (Continue reading)

How to test a custom React hook component

· Reading time: ~3 minute(s) (624 words) programming javascript react testing

As part of my GameBrowser side-project, I’m at the stage where I wanted to start improving the UI a bit. This included needing to define a way of filtering the servers in the list, because they’re all saved together at the moment. As a first attempt, I opted for a simple Dropdown control and decided to make it generic using a custom React Hook. The result was the creation of useDropdown. (Continue reading)

Basic Setup for React Projects in 2020

· Reading time: ~7 minute(s) (1447 words) programming javascript react

I’ve seen a lot of people using project initialisation tools to create their new React projects over the years, in particular create-react-app. While I do see there are some benefits to these tools (in particular for newcomers), these tools do have their disadvantages. I cloned a repository the other day which was using create-react-app, and an npm i installed over 2000 packages! This is a hell of a lot to download just to be able to run some code locally. (Continue reading)

Convert JavaScript Number to Number Array

· Reading time: ~1 minute(s) (89 words) programming javascript

I had a number which I wanted converting into an array where each digit of the number was an item in the array. I tried a few different ways of doing this but always ended up with a string array which wasn't what I wanted. (Continue reading)

React.js Unit Testing with Jest and Enzyme

· Reading time: ~3 minute(s) (524 words) programming javascript reactjs testing

I've written loads of unit tests in my lifetime for C# and JavaScript, but never gotten around to writing any for testing the actual React components because there's always been something more pressing. Time to put that right and take the plunge. (Continue reading)

Map() support in JavaScript ES6/ES2015

· Reading time: ~2 minute(s) (329 words) programming javascript

ECMAScript 6/2015 has brought a lot of new things to the world of JavaScript, and Map() is one of them. However, not all browsers are too keen on particular ways of using it... (Continue reading)

Rendering an array of data as a clickable list using React.js

· Reading time: ~2 minute(s) (348 words) programming javascript reactjs

React.js is great for quickly rendering arrays of data in a tabular format, and there's loads of grid-like packages out there in npm, but sometimes you just need to hand-crank something yourself. Which is fine, until you want the row to be clickable... (Continue reading)

React.js Tutorials

· Reading time: ~1 minute(s) (135 words) programming javascript reactjs

I've created a few pages on here which are now growing into a bit of a tutorial, so thought I'd collate the links into one post (and append links to any new related posts in the future) so it's easier to follow. (Continue reading)