Skip to content

Instantly share code, notes, and snippets.

View Haqverdi's full-sized avatar
🏠
Working from home

Haqverdi Behbudov Haqverdi

🏠
Working from home
  • Azerbaijan, Baku
View GitHub Profile
@Haqverdi
Haqverdi / craco-babel-optional-chaining-plugin.js
Created November 23, 2019 10:43
craco babel config ovveride for use @babel/plugin-proposal-optional-chaining
// craco babel config ovveride for use @babel/plugin-proposal-optional-chaining
// info: https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining
// craco: https://github.com/gsoft-inc/craco
module.exports = {
overrideCracoConfig: ({ cracoConfig }) => {
cracoConfig.babel.plugins.push([
'@babel/plugin-proposal-optional-chaining',
]);
@Haqverdi
Haqverdi / api.js
Last active August 15, 2020 16:04
Custom redux middleware and setup for hanlde api calls
import { createAction } from 'redux-starter-kit';
export const apiStart = createAction('apiStart');
export const apiEnd = createAction('apiEnd');
export const accessDenied = createAction('accessDenied');
export const apiError = createAction('apiError');
@Haqverdi
Haqverdi / useRequiredFields
Last active August 1, 2019 10:32
Custom hook for check required fields
// useRequiredFields.js
import { useState } from 'react'
function useRequiredFields(requiredIds) {
// have all the required fields been filled?
const [requirementsFilled, setRequirementsFilled] = useState(false)
// keep an array of the field ids that have been filled
const [fieldsFilled, setFieldsFilled] = useState([])
@Haqverdi
Haqverdi / sw.js
Created December 21, 2018 06:54 — forked from ireade/sw.js
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}