This is my own personal and preferred API hook made myself for React. This is mainly made to prevent redundancy and version obsolescence across my own projects.
To prevent writing the same code across all my projects, as well as keeping the scripts up to date.
- Wrap project in the context provider from the package.
- Create a configuration. This can be done by either satisfying the
Config
interface/type, and applying it as a prop to the provider, or using thecreateConfig
function, which returns an object of typeConfig
, which you again apply as a prop. - Use
useApi
with type parameters to take use of the package/hook.