Skip to content

Instantly share code, notes, and snippets.

View nurmdrafi's full-sized avatar
:octocat:
Focusing

Nur Mohamod Rafi nurmdrafi

:octocat:
Focusing
View GitHub Profile

usePagination.js

export const usePagination = ({
  totalCount,
  pageSize,
  siblingCount = 1,
  currentPage
}) => {
  const paginationRange = useMemo(() => {
    const totalPageCount = Math.ceil(totalCount / pageSize);
import React, { useState } from 'react';
import {Form, Row, Col, Input, Button, Switch, } from 'antd'
const { TextArea } = Input;
const DynamicCheckbox = () => {

    // States
    const [form] = Form.useForm()
    const [selectedBox, setSelectedBox] = useState(null)
    const PaymentInfo = Form.useWatch('payment_information', form);
@nurmdrafi
nurmdrafi / MapGL Snippet.md
Created January 25, 2023 17:11
MapGL Snippet

Index

@nurmdrafi
nurmdrafi / Ant Design Snippet.md
Last active June 20, 2023 06:51
Ant Design Snippet

Index

Centered Form

// Import Components
import { Form, Input, Button, Row, Col, Spin, Checkbox } from 'antd'

const Login () => {

    // On Submit
    const _onSubmit = (values) => {

Introduction

  1. TypeScript is a superset of JavaScript. But it doesnot add more feature in JavaScript. It just allow us to write JavaScript as a precise manner so that code get less error at runtime.

  2. TypeScript is all about type safety

  3. TypeScript only job is Static Checking which means it checks type on runtime and shows error while we are writing code

  4. TypeScript transpile code into JavaScript

@nurmdrafi
nurmdrafi / Redux createAsyncThunk.md
Last active April 4, 2023 14:28
Redux State CRUD with createAsyncThunk

Action

import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

// Import API's
import { API } from "../../App.config";

// Token & Headers
const token = localStorage.getItem('token')
@nurmdrafi
nurmdrafi / next-note.md
Last active January 20, 2023 06:19
Next.js v13

Benefits

[*] Good for SEO
[*] Super Fast
[*] Future of React

Diff

[*] Next.js provides Server Side Rendering (S.S.R)
[*] React only provides Client Side Rendering

_app vs _document

ParentComponent.js

import React, { useEffect, useState } from "react";
import Highlighter from "react-highlight-words";

// Import Icons
import { SearchOutlined } from "@ant-design/icons";

// Import Components
import { Button, Input, Row, Space, Tag, Col } from "antd";

store.js

import { configureStore } from "@reduxjs/toolkit";
import postsReducer from "./reducers/postsReducer";

export const store = configureStore({
  reducer: {
    posts: postsReducer,
  },
});