Saransh Kataria

How to write your own custom React hooks

How to write your own custom React hooks

  • January 12, 2021

If you have been using react for a while, chances are you have come across the need to extract some logic into a reusable function. And with React hooks coming into the picture, doing this has become a walk in the park. We can write our own custom react hooks...

How to develop your curiosity for a better self?

How to develop your curiosity for a better self?

  • December 29, 2020

Curiosity is the reason why most of the breakthrough discoveries and remarkable inventions have happened throughout history. In the absence of curiosity, there would not have been an impulse to seek new information or experiences. Exploring possibilities is what defines human nature and thus curiosity is an integral part of...

Provide callback to useState hook like setState

Provide callback to useState hook like setState

  • December 15, 2020

If you have been writing class components for a while, you might be familiar with the callback functionality that the setState function provides. setState allows a second parameter to be passed to it as a callback. The callback function is invoked whenever the state of the function gets updated. But,...

Resolving nested queries in GraphQL

Resolving nested queries in GraphQL

  • December 8, 2020

When creating a GraphQL server with relational data, we want to return the data in a hierarchical format with those relationships in a single query. After all, that is where GraphQL comes in handy, right? Let us look into how we can do this using nested queries in GraphQL. This...

Creating a GraphQL API with Apollo Server

Creating a GraphQL API with Apollo Server

  • December 2, 2020

One of the many complaints about the GraphQL ecosystem is that there is a lot of indirection around what packages to use to create a GraphQL application. Even after selecting one, there is a lot of boilerplate code that one must create to make a GraphQL server work. While that...

How to unit-test a private (non-exported) function in JavaScript

How to unit-test a private (non-exported) function in JavaScript

  • November 19, 2020

When writing unit-tests for JavaScript modules, we often encounter a dilemma wherein the module has some private functions that have not been exported. Testing a function that has been exported is easy since it can be imported in the unit testing framework, and the functionality can be tested. But how...

Detecting click outside component using React hooks

Detecting click outside component using React hooks

  • November 10, 2020

If you have tried developing your own dropdown, modal, or popover in React, you would have come across this. “How do I detect a click outside my react component so that I can close it?” Detecting click outside component is luckily is not that difficult. This post will use react...

Beating JSON performance using Protocol Buffers

Beating JSON performance using Protocol Buffers

  • October 20, 2020

Protocol buffers or Protobuf, is a binary format that was created by Google to serialize structured data that is transferred among services. Before we get into what protocol buffers are, let us first look into JSON. JSON clearly has great advantages when it comes to being a data interchange format...