fixed perf issue related to too many rerenders

rerenders were caused by strict equality check on object/array picks
switched artistInfo to new store
updated zustand and fixed deprecation warnings
This commit is contained in:
austinried
2022-03-19 09:52:01 +09:00
parent 47c65ea8cb
commit 13af6555d3
15 changed files with 108 additions and 142 deletions

View File

@@ -1,10 +1,10 @@
import { selectMusic } from '@app/state/music'
import { Store, useStore } from '@app/state/store'
import { Store, useStore, useStoreDeep } from '@app/state/store'
import { useCallback, useEffect } from 'react'
export const useArtistInfo = (id: string) => {
const artistInfo = useStore(useCallback((state: Store) => state.artistInfo[id], [id]))
const fetchArtistInfo = useStore(selectMusic.fetchArtistInfo)
const artistInfo = useStoreDeep(useCallback(store => store.entities.artistInfo[id], [id]))
const fetchArtistInfo = useStore(store => store.fetchLibraryArtistInfo)
useEffect(() => {
if (!artistInfo) {