Skip to content

Instantly share code, notes, and snippets.

@mtbrock
mtbrock / useUndoState.jsx
Created September 11, 2023 06:06
React useUndoState - a hook for using state with history
import React, { useRef, useState } from "react";
function update(past, future, setState, setCanRedo, setCanUndo) {
setState(past.current[past.current.length - 1]);
setCanRedo(future.current.length > 0);
setCanUndo(past.current.length > 1);
}
export default function useUndoState(initialValue) {
const past = useRef([initialValue]);
# Compilations
- [March 2019 - Where to Eat in Savannah](https://www.reddit.com/r/savannah/comments/b3csri/march_2019_where_to_eat_in_savannah/)
- [Best Bars & Restaurants in Savannah](https://www.reddit.com/r/savannah/comments/5qhvgi/best_bars_restaurants_in_savannah/)
- [Recommended Bars](https://www.reddit.com/r/savannah/comments/8g8yf5/recommended_bars_updated_2018/)
# Breweries
Two Tides seems like the most highly recommended
> Southbound: music based names for beer. Industrial brewery vibe. (Close to downtown)
>

Keybase proof

I hereby claim:

  • I am mtbrock on github.
  • I am mattbrock (https://keybase.io/mattbrock) on keybase.
  • I have a public key ASADlP7q4_-rea4i5Gypl_1k4BVmPFXVqDglPK8x_Bj3dAo

To claim this, I am signing this object: