import { useState, useEffect } from 'react'
import { Registry } from 'cozy-client'

const useAppsInMaintenance = client => {
  const [appsInMaintenance, setAppsInMaintenance] = useState([])
  const registry = new Registry({
    client
  })

  useEffect(() => {
    const fetchData = async () => {
      const newAppsInMaintenance = await registry.fetchAppsInMaintenance()
      if (newAppsInMaintenance.length !== appsInMaintenance.length)
        setAppsInMaintenance(newAppsInMaintenance)
    }
    fetchData()
  })

  return appsInMaintenance
}

export default useAppsInMaintenance

import { useState, useEffect } from 'react'
import { Registry } from 'cozy-client'

const useAppsInMaintenance = client => {
  const [appsInMaintenance, setAppsInMaintenance] = useState([])
  const registry = new Registry({
    client
  })

  useEffect(() => {
    const fetchData = async () => {
      const newAppsInMaintenance = await registry.fetchAppsInMaintenance()
      setAppsInMaintenance(newAppsInMaintenance)
    }
    fetchData()
  }, [])

  return appsInMaintenance
}

export default useAppsInMaintenance

Set maintenance hook dependencies to avoid re-renders and re-queries
fix: Set maintenance hook dependencies to avoid re-renders and re-queries
