Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanups #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dist-ssr
*.sw?
.vercel

.env
.env
.partykit
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"useTabs": true,
"singleQuote": true,
"semi": false
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
},
"dependencies": {
"@tldraw/tldraw": "^2.0.0-canary.f7ae99dd1fc9",
"partykit": "^0.0.27",
"partysocket": "^0.0.17",
"partykit": "^0.0.59",
"partysocket": "^0.0.18",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"concurrently": "^8.2.0",
"eslint": "^8.45.0",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@vitejs/plugin-react": "^4.2.1",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.3.3",
"vite": "^5.0.10"
}
}
15 changes: 7 additions & 8 deletions src/useSyncStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
uniqueId,
} from '@tldraw/tldraw'
import { useEffect, useState } from 'react'
import PartySocket from 'partysocket'
import { usePartySocket } from 'partysocket/react'

const clientId = uniqueId()

Expand All @@ -34,12 +34,12 @@ export function useSyncStore({
status: 'loading',
})

useEffect(() => {
const socket = new PartySocket({
host: hostUrl,
room: `${roomId}_${version}`,
})
const socket = usePartySocket({
host: hostUrl,
room: `${roomId}_${version}`,
})

useEffect(() => {
setStoreWithStatus({ status: 'loading' })

const unsubs: (() => void)[] = []
Expand Down Expand Up @@ -159,9 +159,8 @@ export function useSyncStore({
return () => {
unsubs.forEach((fn) => fn())
unsubs.length = 0
socket.close()
}
}, [store])
}, [socket, store])

return storeWithStatus
}
Loading