File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,20 @@ You can now use the `useNostr` and `useNostrEvents` hooks in your components!
4040import { useNostrEvents , dateToUnix } from " nostr-react" ;
4141
4242const GlobalFeed = () => {
43- const { isLoading, events } = useNostrEvents ({
43+ const { events, unsubscribe } = useNostrEvents ({
4444 filter: {
4545 kinds: [1 ],
4646 since: dateToUnix (new Date ()), // all new events from now
4747 },
4848 });
4949
50+ useEffect (() => {
51+ // Stop subscribing when component unmounts:
52+ return () => {
53+ unsubscribe ();
54+ };
55+ }, []);
56+
5057 return (
5158 <>
5259 { events .map ((event ) => (
@@ -63,7 +70,7 @@ const GlobalFeed = () => {
6370import { useNostrEvents } from " nostr-react" ;
6471
6572const ProfileFeed = () => {
66- const { events } = useNostrEvents ({
73+ const { events, unsubscribe } = useNostrEvents ({
6774 filter: {
6875 authors: [
6976 " 9c2a6495b4e3de93f3e1cc254abe4078e17c64e5771abc676a5e205b62b1286c" ,
@@ -73,6 +80,13 @@ const ProfileFeed = () => {
7380 },
7481 });
7582
83+ useEffect (() => {
84+ // Stop subscribing when component unmounts:
85+ return () => {
86+ unsubscribe ();
87+ };
88+ }, []);
89+
7690 return (
7791 <>
7892 { events .map ((event ) => (
You can’t perform that action at this time.
0 commit comments