How to Deal With Circular Dependencies in React Hooks

Brandon Conway
Jul 28, 2020 · 5 min read
Photo by Matt Seymour on Unsplash

July 27, 2020

TL;DR

// This hook provides a ref which is perpetually up to date but will
// not trigger any renders. This is useful for resolving circular
// references in dependency arrays.
export default function useNoRenderRef(currentValue) {
const ref = useRef(currentValue);