Skip to content

Instantly share code, notes, and snippets.

View hunghg255's full-sized avatar
:octocat:
Make Frontend Better 👨‍💻

Hung Hoang hunghg255

:octocat:
Make Frontend Better 👨‍💻
View GitHub Profile
@hunghg255
hunghg255 / reactjs-interview-tips.md
Created July 6, 2020 05:59 — forked from paulnguyen-mn/reactjs-interview-tips.md
Bí kíp cho buổi phỏng vấn ReactJS thành công 🎉

Bí kíp cho buổi phỏng vấn ReactJS thành công 🎉

From unplash.com

AGENGA:

  1. Một vài lưu ý chung
  2. Ôn tập kiến thức JS/ReactJS
  3. Cày thuật toán, giải thuật
  4. Tìm hiểu về công ty mà mình xin ứng tuyển
@ladifire
ladifire / ExampleComponent.tsx
Created January 3, 2022 03:58
Demonstrate how to use Error boundary component in Reactjs
import React from 'react';
import { withErrorBoundary } from 'components/common/MartyErrorBoundary';
export const ExampleComponent = () => {
return (
<div>
Component
</div>
);
@hunghg255
hunghg255 / cache-demo.js
Created November 10, 2023 16:17
Cache Demo
const pendingFns = {};
const runOnce = (fn, key) => {
if (!pendingFns[key]) {
pendingFns[key] = new Promise((resolve, reject) => {
fn().then(resolve).catch(reject)
})
}
return pendingFns[key];
}
@hunghg255
hunghg255 / Use.tsx
Last active December 5, 2023 11:08
Nextjs lazy load component
const Test = lazyLoadHydrate(
() => import('@components/Test/Test'),
true,
() => <div style={{ height: 300 }} />,
);
@hunghg255
hunghg255 / readme.md
Last active December 20, 2023 03:18
SVG Icon với CSS thuần
  • Cách cơ bản: Dùng svg qua thẻ img hoặc là dùng content của svg trong html

  • Cách tiếp cận tiếp theo là chuyển hết svg icon thành một bộ font rồi load bộ font,css đó vào source code, sử dùng bên html chỉ cần thêm class của icon.

    • Cách này sẽ có nhược điêm là không convert được icon multilplechrome
  • Cách tiếp theo là chỉ cần chuyển svg thành dataURI rồi dùng trong css, bên html sẽ thêm class icon

    • Cũng có một source họ dựng svg dùng với css css.gg nhưng bị giới hạn icon và cách họ xử lý cũng phức tạp.
  • HTML

@hunghg255
hunghg255 / reset.css
Created February 15, 2024 06:48
Reset CSS
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:where([hidden]:not([hidden='until-found'])) {
display: none !important;
@hunghg255
hunghg255 / createComponent.ts
Created May 22, 2024 07:47
Script Create Component
//@ts-nocheck
import { exec } from 'node:child_process';
import fs from 'node:fs';
import inquirer from 'inquirer';
/**
* @returns { Promise<string> }
*/
const chooseComponentDirectory = async (
@hunghg255
hunghg255 / detect-recursion-functions.js
Last active July 19, 2024 07:45
detect-recursion-functions.js
// npm i @babel/parser @babel/traverse -D
const fs = require('node:fs');
const path = require('node:path');
const traverse = require('@babel/traverse').default;
const parser = require('@babel/parser');
// Change dir folder
@KristofferEriksson
KristofferEriksson / useLocation.ts
Created February 11, 2024 16:44
A React Typescript hook that provides real-time geolocation data, complete with heading and speed metrics
import { useEffect, useState } from "react";
interface LocationOptions {
enableHighAccuracy?: boolean;
timeout?: number;
maximumAge?: number;
}
interface LocationState {
coords: {
@hunghg255
hunghg255 / Dockerfile
Last active November 19, 2024 01:59
React Static Docker Nginx
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat