Skip to content

Instantly share code, notes, and snippets.

View createdbymahmood's full-sized avatar

Mahmood Bagheri createdbymahmood

View GitHub Profile
@createdbymahmood
createdbymahmood / useRequest.tsx
Last active September 13, 2020 06:36
Making a get request using axios & SWR
import useSWR, { ConfigInterface, responseInterface } from "swr";
// you can import the next line from your axios instance repository
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
export type GetRequest = AxiosRequestConfig | null;
interface Return<Data, Error>
extends Pick<
responseInterface<AxiosResponse<Data>, AxiosError<Error>>,
@createdbymahmood
createdbymahmood / Button.tsx
Last active January 9, 2021 05:01
This is how I render a react Button component with different conditions
import React from 'react';
import classnames from 'classnames';
// * these are the base custom button props
type ButtonSizeType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
type ButtonTypeType =
| 'primary'
| 'info'
| 'light-info'
| 'warning'
@createdbymahmood
createdbymahmood / Text.tsx
Last active August 28, 2020 17:25
This is how I render a react Text component with different conditions using Tailwindcss
import React from 'react';
// * modules
import classnames from 'classnames';
// define all text types
type VariantProps = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p';
type LineheightProps =
| 'none'
| 'light'