Logo
Chakra-UIReactJsNext.JS
Head

@codecraftkit

Documentation

Hooks

Description#

Hooks is package that has a bundle of useful hooks to use in the project.

Installation#

Install Hooks package#

Code Example

npm install @codecraftkit/hooks

External dependencies#

Code Example

npm i @apollo/client graphql moment react-translate

Install each one separated#

Some components their own standalone package

Hooks Example#

useDataTable#

The useDataTable is a hook that is used to manage the DataTable along with the Paginate and a custom filter.

Code Example

const [dataTable, paginate, filter, { refreshList }] = useDataTable(useDataTableProps);

useGqlMutation#

This is a hooks use to mutate Data from graphql, it use the useMutation hook from @apollo/client

Code Example

const [data, call, loading, error] = useGqlMutation(QUERY);

useGqlQueryRequest#

This is a hooks use to get Data from graphql, it use the useQuery hook from r@apollo/client

Code Example

const [data, call, loading, error] = useGqlQueryRequest('collection', QUERY);

useApiRequest#

This is a hooks use to get Data from any api

Code Example

const {data, call, loading, error} = useApiRequest(api, 'path');

useCometRequest#

This is a hooks use to get Data from comet

Code Example

const {data, call, loading, error} = useCometRequest('path');

useTranslate#

This is a hooks to manage translation, it uses react-translate, the language context must be set in order to work

Code Example

const translate = useTranslate()

useTypeAHead#

This is a hooks used with the FormField Type a head

Code Example

const [call, loading] = useTypeAHead({
path: 'path',
customSend: search => ({
number: search
})
})

Hooks List#

component

useDataTable

useGqlMutation

useGqlQueryRequest

useApiRequest

useCometRequest

useTranslate

useTypeAHead