Hooks are a powerful feature in our framework that allow you to add custom functionality to your applications. Below is a comprehensive reference guide to all the hooks available.

Available Hooks

  • useFetch: Fetches data from an API and returns it.
  • useEffect: Executes a function after a component mounts or updates.
  • useContext: Accesses the value of a context.
  • useReducer: A hook that manages state logic in a component.

Usage

Here's an example of how to use the useFetch hook:

import { useFetch } from '/en/docs/hooks';

const { data, error, isLoading } = useFetch('/api/data');

if (isLoading) return 'Loading...';
if (error) return 'An error occurred: ' + error.message;

return <div>{data}</div>;

For more information on hooks, check out our Hooks Overview.

Hooks Illustration