Skip to content

Instantly share code, notes, and snippets.

View HuyAms's full-sized avatar

Huy Trinh HuyAms

  • AlphaSense
  • Helsinki
View GitHub Profile
## Prerequisite: Basic knowledge about [React](https://reactjs.org/) and [Refs and the dom](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs) in React
This post is going to talk about what is **useRef** hook and when we can use it.
The first time I learned Hooks, I have so many questions that I need to look for the answers. One of those questions is how I can compare the current state/props with the previous one or handle deep object comparison in **useEffect Hook**. I would only figure it out when I learned about **useRef Hook** then every pieces fall into place.
💪 Let's get started!
## 1. What is useRef hook?
# Specify a base image
FROM node:alpine
WORKDIR /usr/app
# Install some dependencies
COPY ./package.json ./
RUN npm install
COPY ./ ./
// Dockerfile.dev
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY ..