Skip to content

Instantly share code, notes, and snippets.

View KooperL's full-sized avatar
// todo

Kooper Lingohr KooperL

// todo
View GitHub Profile
@KooperL
KooperL / useFetch.js
Created October 13, 2023 13:05
React centralised API state handler - reduce boilerplate code
import { useCallback, useState } from 'react'
export const fetchStatus = {
none: 0,
loading: 1,
success: 2,
error: 3,
}
export const useFetch = () => {
#!/bin/bash
yarn lint
linting_result=$?
if [[ $linting_result -ne 0 ]]
then
echo "LINT FAILED!"
echo 'Please fix linting problems before committing.'
exit 1