hooks/useSpeedLimitFilter.tsx

src/ui/components/widgets/SpeedLimitSection/hooks/useSpeedLimitFilter.tsx
mail@pastecode.io avatar
unknown
typescript
24 days ago
786 B
1
Indexable
Never
import { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { actionCreatorsProps, speedLimitStates } from '../types'

function useTripReviewFilter(
  state: speedLimitStates,
  actions: actionCreatorsProps
) {
  const dispatch = useDispatch()
  const { routesByRailroad } = useSelector((state: any) => state.portalData)
  const [routes, setRoutes] = useState<any[]>()

  useEffect(() => {
    const fetchFilterData = async () => {
      setRoutes(routesByRailroad?.data)
      actions.onInitRoutes(routesByRailroad?.data)
    }
    fetchFilterData()
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [routesByRailroad])
  return {
    routes: routes || []
  }
}

export default useTripReviewFilter
Leave a Comment