- Used useCallback to improve the performance
This commit is contained in:
parent
df973c3992
commit
abc0bc54d5
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useState } from 'react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import ReactRouterPropTypes from 'react-router-prop-types'
|
||||
import gql from 'graphql-tag'
|
||||
import { Query } from 'react-apollo'
|
||||
|
@ -51,7 +51,8 @@ function AlbumPage({ match }) {
|
|||
match.params.subPage === 'favorites'
|
||||
)
|
||||
|
||||
const toggleFavorites = refetch => {
|
||||
const toggleFavorites = useCallback(
|
||||
refetch => {
|
||||
const newState = !onlyFavorites
|
||||
if (
|
||||
(refetchNeededAll && !newState) ||
|
||||
|
@ -73,7 +74,9 @@ function AlbumPage({ match }) {
|
|||
'',
|
||||
'/album/' + albumId + (newState ? '/favorites' : '')
|
||||
)
|
||||
}
|
||||
},
|
||||
[onlyFavorites, setOnlyFavorites]
|
||||
)
|
||||
|
||||
return (
|
||||
<Query query={albumQuery} variables={{ id: albumId, onlyFavorites }}>
|
||||
|
|
Loading…
Reference in New Issue