Skip to content

Commit

Permalink
fix(utils): useRefCache returns non-mutable object
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Jan 30, 2022
1 parent c43cd31 commit b696b72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/utils/src/useRefCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MutableRefObject, useEffect, useRef } from "react";
import { useEffect, useRef } from "react";

/**
* This hook allows you to provide anything that should be "cached" and puts it
Expand All @@ -11,7 +11,7 @@ import { MutableRefObject, useEffect, useRef } from "react";
* @param cacheable - The cacheable thing that gets updated after each render.
* @returns a mutable ref object containing the current cache.
*/
export function useRefCache<T>(cacheable: T): MutableRefObject<T> {
export function useRefCache<T>(cacheable: T): { readonly current: T } {
const ref = useRef(cacheable);
useEffect(() => {
ref.current = cacheable;
Expand Down

0 comments on commit b696b72

Please sign in to comment.