refactor: optimize note interaction data processing
This commit is contained in:
9
src/hooks/useNoteStatsById.tsx
Normal file
9
src/hooks/useNoteStatsById.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import noteStats from '@/services/note-stats.service'
|
||||
import { useSyncExternalStore } from 'react'
|
||||
|
||||
export function useNoteStatsById(noteId: string) {
|
||||
return useSyncExternalStore(
|
||||
(cb) => noteStats.subscribeNoteStats(noteId, cb),
|
||||
() => noteStats.getNoteStats(noteId)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user