When you first load a url the browser performs a document request, and under the hood it will look something like this: You can see here that we are provided with things like a doctype and meta tags. Most consumer facing websites will constantly be trying to improve their traffic, one way to achieve this… Continue reading React – SPA meta tag limitations
Category: React
React – keep JSX simple
Consider this code: Nothing inherently wrong here, but I do think this this code could be a little bit cleaner, and to be honest what I am about to point out could be considered very subjective, but I think it is worth at least considering. I believe JSX should stick to a document (markup) style… Continue reading React – keep JSX simple
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
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?
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
Jest/React – mocking async functions
Let’s say you have a component that calls to an API in a useEffect. This API data will be used to update some component state. When writing a component test you will want to mock this API call and provide a stub for it. Many times I have seen code that looks like this: What… Continue reading Jest/React – mocking async functions
Javascript first, React later…
React is very hot stuff right now, most aspiring web developers will probably end up looking at it. Sometimes being to eager to jump head first into a library like React means you end up having this problem: I know React but I don’t know Javascript Well why is this a problem? Not understanding the… Continue reading Javascript first, React later…