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

responsive navbar

const Navbar = () => {
  const [openMenu, setOpenMenu] = useState(false);
  return (
    <div>
      {/* mobile menu opener icon */}
      <div className="menuIcon">
        <MenuOutlined onClick={() => setOpenMenu(true)} />
      </div>
https://www.youtube.com/watch?v=7exOfIAKuWU&list=LL&index=2&t=35s

 // 1. using default fetch, useEffect, useState

const [data, setData] = useState([]);
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
	const fetchData = async () => {
		const res = await fetch(url);

store.js

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

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

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";
@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

@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')

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 / 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) => {