mirror of
https://github.com/amark/gun.git
synced 2025-06-07 14:46:44 +00:00
clean up subscription when component unmounts
This commit is contained in:
parent
156b84acee
commit
8ec8e394b8
@ -13,10 +13,10 @@
|
|||||||
const [todos, setTodos] = React.useState({})
|
const [todos, setTodos] = React.useState({})
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
gun
|
return gun
|
||||||
.get("todos")
|
.get("todos")
|
||||||
.map()
|
.map()
|
||||||
.on((todo, id) => setTodos(todos => ({...todos, [id]: todo })));
|
.on((todo, id) => setTodos(todos => ({...todos, [id]: todo }))).off;
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user