Avoiding state update on unmounted React component within useEffect hook

The hooks introduced with React 16.8 are a nice way to control state and other features on functional React components. They discard the necessity of third-party libraries such as Recompose – which is the inspiration for React hooks, by the way. One way one can apply the useEffect hook, for example, is to mimic the […]

Custom setters with React useState hook

One of the recent additions to React was its hooks. With that, developers don’t need to rely on libraries such as Recompose to add state (and other features) to functional components. If you’re one of those devs and were used to create custom setters for states, it’s possible you find the new useState hook somewhat […]

Laravel and NodeJS messaging using Redis Pub/Sub

I was recently working on this project that was composed of two different parts: a web application built in PHP with Laravel, and an AWS Lambda function written in NodeJS. In the past, both applications exchanged data using a common MySQL database. With time, this setup showed up very inefficient. As the number of “messages” sent and […]

Using MutationObserver API and undo.js to track DOM changes

I was recently working on this project that had a kind of drag and drop builder. Users should be able to drag items into a specific building area to assembly stuff — I’m sorry for not giving more details, by the time I’m writing this the product is not yet released. One of the features I […]

Passing Node args to Mocha tests

This is a really quick tip. I was looking around on the internet for a way to pass Node arguments when calling Mocha binary. And I couldn’t find anything useful. Then I tried the following and it worked: $ test node –expose-gc ./node_modules/.bin/mocha […] The –expose-gc argument is just an example. You can pass any argument accepted […]

Mixing HTTP and WebSocket routes in a Koa-based application

I’ve started to use the koa-websocket package. And it took me some time to figure out how to mix HTTP and WebSocket routes in a single Koa-based application. I’m not sure if this solution is obvious, but I’m sharing it anyway. First of all, we’ll need two separate routers for regular HTTP and WebSocket routes: // Creating […]

Simple Gallery — Uma simples galeria baseada em jQuery

Na maioria dos projetos que desenvolvemos na CodeKings, acabamos não conseguindo usar as opções de galerias disponíveis na web. Isso acontece porque a estrutura do plugin não é compatível com o layout ou faz muito mais coisas do que realmente precisamos. Nesses casos, acabamos escrevendo um script simples que resolve mais rapidamente do que se […]

Funções úteis em JS para extrair dados de URLs

Existem bibliotecas bem legais para extrair dados da URL, mas às vezes você não precisa de todas aquelas informações. Para evitar que seu código fique inchado ou a importação de bibliotecas completas, pode ser interessante usar funções específicas que retornam apenas o dados que você precisa. Tem duas delas que uso com bastante frequencia: Hash […]