mirror of
https://github.com/amark/gun.git
synced 2025-06-05 21:56:51 +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({})
|
||||
|
||||
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 (
|
||||
|
Loading…
x
Reference in New Issue
Block a user