Update system-react
This commit is contained in:
parent
37948d1579
commit
ca2c9130aa
@ -6,18 +6,16 @@ Sample:
|
||||
|
||||
```js
|
||||
import { useMemo } from "react";
|
||||
import { useRequestBuilder, useUserProfile } from "@snort/system-react";
|
||||
import { FlatNoteStore, NostrSystem, RequestBuilder, TaggedNostrEvent } from "@snort/system";
|
||||
import { SnortContext, useRequestBuilder, useUserProfile } from "@snort/system-react";
|
||||
import { NostrSystem, NoteCollection, RequestBuilder, TaggedNostrEvent } from "@snort/system";
|
||||
|
||||
// singleton nostr system class
|
||||
const System = new NostrSystem({});
|
||||
|
||||
// some bootstrap relays
|
||||
["wss://relay.snort.social", "wss://nos.lol"].forEach(r => System.ConnectToRelay(r, { read: true, write: false }));
|
||||
|
||||
export function Note({ ev }: { ev: TaggedNostrEvent }) {
|
||||
// get profile from cache or request a profile from relays
|
||||
const profile = useUserProfile(System, ev.pubkey);
|
||||
const profile = useUserProfile(ev.pubkey);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -35,7 +33,7 @@ export function UserPosts(props: { pubkey: string }) {
|
||||
return rb;
|
||||
}, [props.pubkey]);
|
||||
|
||||
const data = useRequestBuilder < FlatNoteStore > (System, FlatNoteStore, sub);
|
||||
const data = useRequestBuilder(NoteCollection, sub);
|
||||
return (
|
||||
<>
|
||||
{data.data.map(a => (
|
||||
@ -46,6 +44,10 @@ export function UserPosts(props: { pubkey: string }) {
|
||||
}
|
||||
|
||||
export function MyApp() {
|
||||
return <UserPosts pubkey="63fe6318dc58583cfe16810f86dd09e18bfd76aabc24a0081ce2856f330504ed" />;
|
||||
return (
|
||||
<SnortContext.Provider value={System}>
|
||||
<UserPosts pubkey="63fe6318dc58583cfe16810f86dd09e18bfd76aabc24a0081ce2856f330504ed" />
|
||||
</SnortContext.Provider>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system-react",
|
||||
"version": "1.0.14",
|
||||
"version": "1.0.15",
|
||||
"description": "React hooks for @snort/system",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@ -16,7 +16,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@snort/shared": "^1.0.6",
|
||||
"@snort/system": "^1.0.20",
|
||||
"@snort/system": "^1.0.21",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user