Skip to content

A React hook for managing complex state with custom actions, history tracking, and type safety.

License

Notifications You must be signed in to change notification settings

rafde/react-hook-use-cta

Repository files navigation

react-hook-use-cta: useCTA (use Call To Action)

Read full document for react-hook-use-cta on documentation website

Install

npm i react-hook-use-cta
yarn add react-hook-use-cta
deno add jsr:@rafde/react-hook-use-cta

useCTA

import { useCTA, } from 'react-hook-use-cta';
const [
	history,
	dispatch
] = useCTA({
	initial: {
		value: 0,
	},
});

createCTA

import { createCTA, } from 'react-hook-use-cta';

const [
	history,
	dispatch
] = createCTA({
	initial: {
		value: 0,
	},
});

createCTAContext

import { createCTAContext, } from 'react-hook-use-cta';

const context = createCTAContext({
	initial: {
		value: 0,
	},
});

export const CTAProvider = context.CTAProvider;
export const useCTAHistoryContext = context.useCTAHistoryContext;
export const useCTADispatchContext = context.useCTADispatchContext;