Skip to content

Instantly share code, notes, and snippets.

View pocojang's full-sized avatar
๐Ÿข

Poco pocojang

๐Ÿข
View GitHub Profile
@seonghyeonkimm
seonghyeonkimm / react-18.md
Last active June 16, 2023 18:37
React 18 ๋ฏธ๋ฆฌ๋ณด๊ธฐ

์ฆ‰์‹œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๊ฐœ์„ ์ 

์ฝ”๋“œ์˜ ๋ณ€๊ฒฝ ์—†์ด React 18๋กœ ์—…๋ฐ์ดํŠธํ•˜์ž๋งˆ์ž ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๊ฐœ์„ ์ ์— ๋Œ€ํ•ด์„œ ๊ฐ„๋‹จํžˆ ์ดํ•ดํ•ด๋ณด์ž.

ย  ์ œ๋ชฉ์—์„œ๋„ ์•Œ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๊ฐ„๋‹จํžˆ ์„ค๋ช…ํ•˜์ž๋ฉด, React 18 ์ด์ „์—๋Š” ์˜ค์ง ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์•ˆ์—์„œ ๋ฐœ์ƒํ•œ setState๋งŒ ๋ชจ์•„์„œ ์ฒ˜๋ฆฌ ํ–ˆ์ง€๋งŒ, React 18 ์ดํ›„๋ถ€ํ„ฐ๋Š” promise, setTimeout ๋“ฑ์—์„œ ๋ฐœ์ƒํ•œ ์—ฐ์†์ ์ธ setState๋„ ๋ชจ์•„์„œ ์ฒ˜๋ฆฌ๋  ์ˆ˜ ์žˆ๋„๋ก ๊ฐœ์„ ๋˜์—ˆ๋‹ค๋Š” ๋‚ด์šฉ์ด๋‹ค.

ย  ์œ„ ๊ธฐ๋Šฅ์„ ํ”ผํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด react-dom์˜ flushSync api๋ฅผ ์ด์šฉํ•˜๋ฉด ๋ชจ์•„์„œ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š๊ณ  ํ•˜๋‚˜์˜ setState๊ฐ€ ๋ฐ”๋กœ re-render๋ฅผ ์ผ์œผํ‚ค๋„๋ก ๋ช…์‹œ์ ์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

@ClickerMonkey
ClickerMonkey / types.ts
Last active August 8, 2024 00:25
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@snaag
snaag / Execution-Context.md
Last active January 12, 2023 00:57
Execution Context

๋“ค์–ด๊ฐ€๋ฉฐ

์ง€๋‚œ JavaScript, Front-End ๋ฐœํ‘œ ์ฃผ์ œ๋Š” this ์˜€์ง€๋งŒ, ๊ณต๋ถ€ํ•˜๋‹ค ๋ณด๋‹ˆ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ์— ๋Œ€ํ•œ ๋‚ด์šฉ์ด ์„ ํ–‰๋˜์•ผ ํ•  ๊ฒƒ ๊ฐ™์•„ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ์— ๋Œ€ํ•˜์—ฌ ๋ฐœํ‘œ๋ฅผ ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

์—ฌ๋Ÿฌ ์ž๋ฃŒ์™€ ์ฑ…์„ ์ฐธ๊ณ ํ•˜๋ฉฐ ๊ณต๋ถ€๋ฅผ ํ•˜๊ณ  ์žˆ์Œ์—๋„ ๋‚ด์šฉ์ด ์ž˜ ์™€๋‹ฟ์ง€ ์•Š์•„ ์ฐธ๊ณ 1์„ ์ฐธ๊ณ 2, ์ฐธ๊ณ 3, ์ฐธ๊ณ 4, ์ฑ… ์ธ์‚ฌ์ด๋“œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ, Poiema Web์„ ์ฐธ๊ณ ํ•˜์—ฌ ๋ฒˆ์—ญ์„ ํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. ์ถ”๊ฐ€์ ์œผ๋กœ ๋‚ด๊ฐ€ ์—ฌ๋Ÿฌ ์ž๋ฃŒ๋ฅผ ์ฐพ์•„๋ณด๋ฉด์„œ ์•Œ๊ฒŒ ๋œ ๋‚ด์šฉ๋“ค๋„ ๋ง๋ถ™์ผ ๊ฒƒ์ด๋‹ค.

์‹คํ–‰ ์ปจํ…์ŠคํŠธ, Execution Context(์ดํ•˜ EC) ๋ผ๋Š” ๊ฐœ๋…์€ ๋‚˜์—๊ฒ ๋‚ฏ์„ค์—ˆ๊ธฐ์— ๋‚˜์™€ ๊ฐ™์€ ์‚ฌ๋žŒ๋“ค์ด ์žˆ์„ ๊ฒƒ ๊ฐ™์•„ ํ”ํžˆ๋“ค ์•„๋Š” ์ฝœ์Šคํƒ ์„ ์‹œ์ž‘์œผ๋กœ ๊ธ€์„ ์จ๋ณด๋„๋ก ํ•˜๊ฒ ๋‹ค.

HTML
- Semantic HTML
- Event delegation
- Accessibility / ARIA
CSS
- Specificity
- Pseudo-elements
- Pseudo-selectors
- Combinators
Data Structures
- Stacks
- Queues
- Linked lists
- Graphs
- Trees
- Tries
Concepts
- Big O Notation
@craigtaub
craigtaub / React-Hooks.js
Last active January 30, 2025 18:55
Nested React Hooks
// Engine
const React = {
index: 0,
state: [],
useEffect: (callback, dependencies) => {
const cachedIndex = React.index;
const hasChanged = dependencies !== React.state[cachedIndex];
if (dependencies === undefined || hasChanged) {
callback();
@velopert
velopert / asyncActionUtils.js
Created July 14, 2019 01:56
React Context + useReducer + async actions example
// ์ด ํ•จ์ˆ˜๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์•ก์…˜์˜ ํƒ€์ž… (์˜ˆ: GET_USER) ๊ณผ Promise ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๋ฐ›์•„์˜ต๋‹ˆ๋‹ค.
export function createAsyncDispatcher(type, promiseFn) {
// ์„ฑ๊ณต, ์‹คํŒจ์— ๋Œ€ํ•œ ์•ก์…˜ ํƒ€์ž… ๋ฌธ์ž์—ด์„ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค.
const SUCCESS = `${type}_SUCCESS`;
const ERROR = `${type}_ERROR`;
// ์ƒˆ๋กœ์šด ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
// ...rest ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚˜๋จธ์ง€ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ rest ๋ฐฐ์—ด์— ๋‹ด์Šต๋‹ˆ๋‹ค.
async function actionHandler(dispatch, ...rest) {
dispatch({ type }); // ์š”์ฒญ ์‹œ์ž‘๋จ
@NoriSte
NoriSte / redux-saga-typeguard.ts
Last active November 1, 2023 02:22
Redux-saga + Typescript: implementing typeguard for Axios AJAX requests
import { AxiosResponse } from "axios";
// the kind of data I expect from the AJAX request...
interface AuthData {
access_token?: string;
refresh_token?: string;
}
// ... a type dedicated to the Axios response...
type AuthResponse = AxiosResponse<AuthData>;
@heygrady
heygrady / render-props.md
Last active August 6, 2024 18:50
Avoiding HOC; Favoring render props
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active March 22, 2025 07:22
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.