Using the Hooks
Breakdown of hooks from the Torque React library
Available Hooks
The Torque React SDK provides several hooks for interacting with the Torque platform:
useCurrentUser: Get the current authenticated useruseProjects: Get a list of projectsuseProject: Get a specific projectuseCreateProject: Create a new projectuseOffers: Get offers for a projectuseOffer: Get a specific offeruseCreateOffer: Create a new offeruseUpdateOffer: Update an existing offeruseStartOffer: Start an offer for the current useruseOfferJourney: Get the user's journey for the current offeruseOfferAction: Perform an action on an offeruseDeployDistributor: Deploy a distributoruseAddDistributor: Add a distributor to a projectuseUpdateDistributor: Update a distributoruseCloseDistributor: Close a distributor
Example: Using the useOffer Hook
import { useOffer } from '@torque-labs/react';
export function Offers() {
const { data: offers, isLoading, error } = useOffers({
status: "ACTIVE"
});
return (
<div>
{offers.map(offer => (
<div key={offer.id}>
<h3>{offer.metadata.title}</h3>
</div>
))}
</div>
);
}Last updated
