From a6bba965fe322147c3640ee31695cca55a41af21 Mon Sep 17 00:00:00 2001 From: shinyoshiaki Date: Mon, 17 Jun 2019 02:33:29 +0000 Subject: [PATCH] fix redux hooks --- src/hooks/useSelectorRef.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/useSelectorRef.tsx b/src/hooks/useSelectorRef.tsx index 46a9f09..a4d37c8 100644 --- a/src/hooks/useSelectorRef.tsx +++ b/src/hooks/useSelectorRef.tsx @@ -2,8 +2,9 @@ import { useSelector } from "react-redux"; import { useRef, useEffect } from "react"; export default function useSelectorRef(selector: (state: any) => T) { - const ref = useRef(); const select = useSelector(selector); + const ref = useRef(select); + useEffect(() => { ref.current = select; }, [select]);