From 4ec0ec293418f6747048c185b0da05c7767133b1 Mon Sep 17 00:00:00 2001 From: Tristan Edwards Date: Tue, 27 Dec 2022 23:27:50 +0100 Subject: [PATCH] Update README examples --- README.md | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index a6c4eef..4a28475 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ import { NostrProvider } from "nostr-react"; const relayUrls = [ "wss://nostr-pub.wellorder.net", - "wss://nostr-relay.untethr.me", + "wss://relay.nostr.ch", ]; function MyApp() { return ( - + ); @@ -40,20 +40,15 @@ You can now use the `useNostr` and `useNostrEvents` hooks in your components! import { useNostrEvents, dateToUnix } from "nostr-react"; const GlobalFeed = () => { - const { events, unsubscribe } = useNostrEvents({ + const now = useRef(new Date()); // Make sure current time isn't re-rendered + + const { isLoading, connectedRelays, events } = useNostrEvents({ filter: { + since: dateToUnix(now.current), // all new events from now kinds: [1], - since: dateToUnix(new Date()), // all new events from now }, }); - useEffect(() => { - // Stop subscribing when component unmounts: - return () => { - unsubscribe(); - }; - }, []); - return ( <> {events.map((event) => ( @@ -70,7 +65,7 @@ const GlobalFeed = () => { import { useNostrEvents } from "nostr-react"; const ProfileFeed = () => { - const { events, unsubscribe } = useNostrEvents({ + const { events } = useNostrEvents({ filter: { authors: [ "9c2a6495b4e3de93f3e1cc254abe4078e17c64e5771abc676a5e205b62b1286c", @@ -80,13 +75,6 @@ const ProfileFeed = () => { }, }); - useEffect(() => { - // Stop subscribing when component unmounts: - return () => { - unsubscribe(); - }; - }, []); - return ( <> {events.map((event) => (