Many times I see code like this: then when it gets passed to a button element: this isn’t wrong in the sense that, the code will still run, because under the hood the DOM is still receiving a reference to a function that can be called when the click event fires, but it is more… Continue reading Javascript – don’t add redundant anonymous functions
Web – compress images!!
I see too many websites containing images which are not compressed. There are many websites/ tools available now that can perform compression on images in an instant, and most of them are free. There are both lossy and lossless compressions available, and of course, lossless will likely yield the best quality retention. You can work… Continue reading Web – compress images!!
React – scalability
Sometimes you see questions online like “is React scalable??” and of course people say yes. After-all it is used on a massive scale by Facebook themselves so we already have some pretty good evidence to back that up. I think the better question now is “how can I make sure React is scalable for my… Continue reading React – scalability
React Hook – asyc request
Think of all the React components that can end up having a useEffect that will call some API which then updates some state to not only hold the value of that but also track request progress, if only there was a way we could abstract some of this away and have dumber components…well consider the… Continue reading React Hook – asyc request
TypeScript – browser Santa Clause
At the beginning of my career I didn’t always enjoy front end development because no matter where you turned Javascript was always lurking, and I didn’t really like it. The dynamic nature of Javascript always made me uneasy because I had been so used to Java. Thankfully the game has really changed, especially because of… Continue reading TypeScript – browser Santa Clause
TypeScript – avoid using “any”
In many Node/ React Typescript repos I have seen, the authors have opted to disable the popular linting rule that complains about using the any type. I don’t think this is a good idea, why is that? Because Typescript is just syntactic sugar I think there is sometimes a temptation to try to “get round… Continue reading TypeScript – avoid using “any”
React – cleanup, when and how?
When using features in React sometimes we need to understand the concept of cleanup. Let’s look at an example using useEffect and useState. A useEffect and component state will only exist for the lifecycle of the component, which means when a component is unmounted it will be removed from memory. There is a nice way… Continue reading React – cleanup, when and how?
Process – infastructure + setup as code
To speed up day to day work and onboarding new developers we should try to leverage setup automation as much as possible. For example, if you use AWS you should be taking an “infastructure as code” approach using the AWS SDK. Another good example is repo setup on a local environment, if you have a… Continue reading Process – infastructure + setup as code
Jest/TypeScript – partial type mock
Consider these types: Let’s say you are testing a component that fires off an API call to retrieve on object that should match IHuman. In your test you will want to create a mock version of this, – usually referred to as stub or a fixture. Let’s look at an example of how that might… Continue reading Jest/TypeScript – partial type mock
React – memory leaks
Consider 2 components – PlaylistsComponent, and PlaylistComponent. PlaylistComponent is only visible via PlaylistsComponent if there are songs related to that playlist and PlaylistComponent holds the count of those songs inside its own component state, the conditional visibility is controlled by PlaylistsComponent. PlaylistComponent can remove songs via a remove function that is passed down from PlaylistsComponent,… Continue reading React – memory leaks