From 8ec8e394b8c7611d25ca5d190b7ab9d928c3ae3f Mon Sep 17 00:00:00 2001 From: Bryan Goldstein Date: Sat, 4 Apr 2020 19:45:47 -0400 Subject: [PATCH] clean up subscription when component unmounts --- examples/react/todo.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/react/todo.html b/examples/react/todo.html index ad2b72f7..05d36303 100644 --- a/examples/react/todo.html +++ b/examples/react/todo.html @@ -13,10 +13,10 @@ const [todos, setTodos] = React.useState({}) React.useEffect(() => { - gun + return gun .get("todos") .map() - .on((todo, id) => setTodos(todos => ({...todos, [id]: todo }))); + .on((todo, id) => setTodos(todos => ({...todos, [id]: todo }))).off; }, []) return (