Using prevState with React, basic and complex

AntoineGGG
Jun 18 · 4 min read
Photo by Karla Hernandez on Unsplash

How to use the famous “prevState” to modify our React state without overriding it !

Let start with a basic exemple (the -famous- counter) :

import "./App.css";
import React, { useState } from "react";
const App = () => {
const [mySuperCounter…