Functional components in React are missing the concept of a Constructor
In class-based object-oriented programming, a constructor (abbreviation: ctor) is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables. ~ wiki link
So, in simple words with a Constructor we initialize the state of our component, and someone could say that “Function components don’t need a constructor. You can initialise the state in the useState call.”
The problem here is that Function components are… functions. They run whenever you call them. Just like that. This means that we don’t have life-cycles, which also means that we don’t have a place in which we can actually initialize our component with a code that runs only once before the component is rendered for the first time. …
This is the second part of the series of use of “MongoDB Realm + GraphQL + Apollo Client (on React)”. You can find the first post of the series with more details here.
This post will describe how we can update or delete one specific document in our Database.
Exactly, as in the previous post, the steps for both scenarios are the following:
Recently I started a personal side project in which I needed to create a DB and consume their data.
I like to experiment on my side projects, so I decided to go with some familiar and some new technologies.
The full stack will be:
I am familiar w/ React, and Mongo and the new parts are GraphQL and the whole “server-less” Mongo Atlas thing.
In this series of posts, I’ll try to gather those things that were not trivial or caused me some confusion in the process. …
About