Features
Fetch on mount only

Fetch on mount

You can use useMount to fetch a resource on mount only.

useMount(query) 

Motivation

Use it when you DON'T want to refetch when the key changes.

Warning

Won't fetch on key change, see useFetch for doing so.

Example

function useHelloMount() {
  const query = useSchema(getHelloSchema, [])
 
  useMount(query)
  return query
}

Implementation

export function useMount(query: Query) {
  const { fetch } = query
 
  useEffect(() => {
    fetch()
  }, [])
}

See also