๋ฐ˜์‘ํ˜•

Framework/React 47

[React] MUI Popover, Menu ์†์„ฑ 'anchorEl' ๋ž€ ๋ฌด์—‡์ด๋ฉฐ ์‚ฌ์šฉ ์ด์œ 

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ์‹œ๊ฐ„์—๋Š” React MUI์—์„œ anchorEl ๋ž€ ๋ฌด์—‡์ด๋ฉฐ ์‚ฌ์šฉ ์ด์œ ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.  anchorEl ?Material-UI (MUI)์—์„œ ํŒ์˜ค๋ฒ„(Popover)๋‚˜ ๋ฉ”๋‰ด(Menu)์™€ ๊ฐ™์€ ์ปดํฌ๋„ŒํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์†์„ฑ์œผ๋กœ, ํŒ์—…์˜ ์œ„์น˜๋ฅผ ์ง€์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. ์ด ์†์„ฑ์€ ํŒ์—…์ด ์—ด๋ฆด ์œ„์น˜์˜ ๊ธฐ์ค€์ด ๋˜๋Š” ์š”์†Œ(Element)๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์ฃผ์š” ์ปดํฌ๋„ŒํŠธ์—์„œ์˜ anchorEl ์‚ฌ์šฉ1. PopoverPopover ์ปดํฌ๋„ŒํŠธ๋Š” ๊ธฐ์ค€ ์š”์†Œ์ธ anchorEl์˜ ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ™”๋ฉด์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. The content of the Popover. 2. MenuMenu ์ปดํฌ๋„ŒํŠธ๋Š” ์ฃผ๋กœ ๋„ค๋น„๊ฒŒ์ด์…˜ ๋˜๋Š” ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. anchorEl์„ ํ†ตํ•ด ๋ฉ”๋‰ด๊ฐ€ ๋‚˜ํƒ€๋‚  ์œ„์น˜๋ฅผ ์ง€์ •..

Framework/React 2024.09.04

[React] react-virtuoso TableVirtuoso ๋นˆ๋ฐฐ์—ด์ผ ๋•Œ EmptyPlaceholder ์†์„ฑ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” TableVirtuoso ์‚ฌ์šฉ ์ค‘ ๋ฐ์ดํ„ฐ๊ฐ€ ๋นˆ ๋ฐฐ์—ด์ผ ๋•Œ EmptyPlaceholder ์†์„ฑ์„ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.  Exampleํ˜„์žฌ ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ด…์‹œ๋‹ค. ์ด ์ƒํƒœ์—์„œ dataList๊ฐ€ null์ด๊ฑฐ๋‚˜ ๋นˆ๋ฐฐ์—ด์ผ ๋•Œ ํŠน์ • ๋ฐ์ดํ„ฐ๊ฐ€ ๋น„์–ด์žˆ๋‹ค๋Š” ํŠน์ • ํ…์ŠคํŠธ๋ฅผ ํ‘œ์‹œํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. const VirtuosoTableComponents = (totalColSpan: number): TableComponents => ({ Scroller: React.forwardRef((props, ref) => ( )), Table: (props) => ( ), TableHead: React.forwardRef((props, ref) => ( ..

Framework/React 2024.09.03

[React] react-virtuoso dynamic height ๋™์  ๋†’์ด ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ• (+ mui)

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” react-virtuoso ์—์„œ ๋™์  ๋†’์ด๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ ์ €๋Š” third-party mui tabler๊ณผ ๊ฒฐํ•ฉํ•˜์—ฌ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.  My casereact-virtuoso mui table ์‚ฌ์šฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. height ๋ฅผ ์„ค์ •ํ•ด์ค„ ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ณ ์ •๊ฐ’์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. export default function ReactVirtualizedTable() { return ( );} ์ œ ์ผ€์ด์Šค์˜ ๊ฒฝ์šฐ ์—ฌ๋Ÿฌ rows ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๊ณ , ๊ทธ ๋ฐ์ดํ„ฐ๋“ค์€ ๊ฐ๊ฐ ๋†’์ด๊ฐ€ ๋‹ฌ๋ผ์„œ height๋ฅผ ๋™์ ์œผ๋กœ ์„ค์ •ํ•ด์ค˜์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์–ด๋–ค ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•ด์•ผ ํ• ๊นŒ์š”?  How to solve the problemimport Re..

Framework/React 2024.09.02

[React] react-virtuoso๋ฅผ ์‚ฌ์šฉํ•œ mui react Table ๋ Œ๋”๋ง ์ตœ์ ํ™” ์„ฑ๋Šฅ๊ฐœ์„  ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” react-virtuoso ๊ฐ€ ๋ฌด์—‡์ด๋ฉฐ, react virtuoso ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ react table ๋ Œ๋”๋ง ์ตœ์ ํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. Issuemui react table์„ ์‚ฌ์šฉํ•˜๋˜ ๋„์ค‘ ๋ฐ์ดํ„ฐ ์–‘์ด ๋งŽ์•„์ง€๋ฉด์„œ ํ…Œ์ด๋ธ”์ด ๊ทธ๋ ค์ง€๋Š” ์†๋„๊ฐ€ ๋Š๋ ค์ ธ ์„œ๋น„์Šค ์ด์šฉ์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.  ๋”ฐ๋ผ์„œ react table์˜ ์„ฑ๋Šฅ์„ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ๊ฐœ์„  ๋ฐฉ์•ˆ์„ ์ฐพ์•„์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.  ๊ด€๋ จ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„œ์น˜ํ•˜๋˜ ๋„์ค‘ TanStack ์™€, mui ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์— Virtualized table ๋ถ€๋ถ„์— ์†Œ๊ฐœ๋˜์–ด ์žˆ๋Š” react-virtuoso ๋‘๊ฐœ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋ฐœ๊ฒฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. star์˜ ์ˆ˜ ์ž์ฒด๋Š” TanStack์ด ๋” ๋†’์•˜์ง€๋งŒ ์‚ฌ์šฉ๋ฐฉ๋ฒ•์ด ๋” ์‰ฝ๊ณ , ๊ธฐ์กด ํ”„๋กœ์ ํŠธ์— ์šฉ์ดํ•˜..

Framework/React 2024.09.01

[React] react-apexcharts y์ถ• (yaxis) ๋‹จ์œ„ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” react-apexcharts ์˜ y์ถ• ๋‹จ์œ„๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.  How to solve the problem๊ธฐ์กด chart options ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ €์˜ ๊ฒฝ์šฐ y์ถ•์ด ํ™”ํ ๋‹จ์œ„์˜€๊ธฐ ๋•Œ๋ฌธ์— ๋ณด๊ธฐ ์‰ฝ๊ฒŒ ์ž๋ฆฟ์ˆ˜ ํ‘œ์‹œ๊ฐ€ ํ•„์š”ํ–ˆ์Šต๋‹ˆ๋‹ค. const options: any = { chart: { height: 250, type: 'bar', stacked: false, toolbar: false, animations: { enabled: true, easing: 'easeinout', speed: 500, }..

Framework/React 2024.07.21

[React] Warning: Failed prop type: Invalid prop checked of type string supplied to ..., expected boolean. Warning ๋ฐœ์ƒ ๋ฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. react ์‚ฌ์šฉ ์ค‘ ๋‹ค์Œ์˜ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. Warning: Failed prop type: Invalid prop checked of type string supplied to ..., expected boolean.  Why?const MemoizedCheckbox: React.FC = React.memo(({ checked, onChange, value }) => { return })... } label={data} labelPlacement='end' /> ์˜ค๋ฅ˜์˜ ์›์ธ์€ MemoizedCheckbox ์ปดํฌ๋„ŒํŠธ์˜ checked prop์— ๋ฌธ์ž์—ด ํƒ€์ž…์ด ์ „๋‹ฌ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. checked prop์€ boolean ํƒ€์ž…์„ ๊ธฐ๋Œ€ํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ๋ฌธ์ž์—ด์ด ์ „..

Framework/React 2024.07.15

[React] react-datepicker ์—๋Ÿฌ date-fns๏ปฟ SyntaxError: Unexpected token 'export' ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. react-datepicker ๋ฅผ ์‚ฌ์šฉํ•˜๋˜ ๋„์ค‘ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. SyntaxError: Unexpected token 'export' How to solve the problem date-fns ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ko (ํ•œ๊ตญ์–ด)๋ฅผ import ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ๋ถ€๋ถ„์—์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋”๋ผ๊ณ ์š”~ import { ko } from 'date-fns/esm/locale' ๊ทธ๋ž˜์„œ ์ด ๋ถ€๋ถ„์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐ”๊ฟ”์คฌ๋”๋‹ˆ ๋” ์ด์ƒ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ํ˜น์‹œ ์ €์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๋ถ„๋“ค์ด ์žˆ์œผ์‹œ๋‹ค๋ฉด ์ด ๋ฐฉ๋ฒ•์„ ํ™œ์šฉํ•ด๋ณด์„ธ์š” :)import { ko } from 'date-fns/locale'https://github.com/date-fns/date..

Framework/React 2024.07.11

[React] react-datepicker ์–ธ์–ด ๋ฐ”๊พธ๊ธฐ (ํ•œ๊ตญ์–ด๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•)

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” react-datepicker ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ์–ธ์–ด๋ฅผ ๋ฐ”๊พธ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ react-datepicker ๋Š” react์—์„œ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ๋‹ฌ๋ ฅ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.  How to Change lang ๊ฐ€์žฅ ๋จผ์ € date-fns๋ฅผ ์„ค์น˜ํ•ด์ค๋‹ˆ๋‹ค. npm์„ ์‚ฌ์šฉํ•˜์‹ ๋‹ค๋ฉด npm์„ ์ด์šฉํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. yarn add date-fns  ์ดํ›„ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ์–ธ์–ด๋ฅผ import ํ•ด์ค๋‹ˆ๋‹ค. import { ko } from "date-fns/esm/locale"; } />  local={ko}๋ฅผ ์ ์šฉํ•œ ๊ฒฐ๊ณผ ์•„๋ž˜์™€ ๊ฐ™์ด ์บ˜๋ฆฐ๋” ์–ธ์–ด๊ฐ€ ํ•œ๊ตญ์–ด๋กœ ๋ณ€๊ฒฝ๋œ ๋ชจ์Šต์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Framework/React 2024.07.10

[React] window scroll event handler ์ด๋ฒคํŠธ๊ฐ€ ์•ˆ๋จนํž ๋•Œ, scrollY always 0

Intro์•ˆ๋…•ํ•˜์„ธ์š”. React์—์„œ window.scroll ์ด๋ฒคํŠธ๊ฐ€ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜์ง€ ์•Š์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์•„๋ฌด๋ฆฌ window.scrollY ๊ฐ’์„ ๊ตฌํ•ด๋„ 0์œผ๋กœ ๋‚˜์˜ค๋”๋ผ๊ณ ์š”.   ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. // stateconst [scrollTop, setScrollTop] = useState(0), headerRef = useRef(null), headerHeight = headerRef?.current?.clientHeight ?? 0, // useEffectuseEffect(() => { const handleScroll = () => { setScrollTop(window.scrollY); }; handleScroll(); window.ad..

Framework/React 2024.05.25

[React] useForm ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ž€?

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” React useForm ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋Œ€ํ•ด ๊ฐ„๋‹จํžˆ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. React mui ํ…œํ”Œ๋ฆฟ์„ ์‚ดํŽด๋ณด๋˜ ๋„์ค‘ useForm ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ถ€๋ถ„์„ ์ฒ˜์Œ ๋ฐœ๊ฒฌํ–ˆ๊ฑฐ๋“ ์š”! :)  UseForm?useForm์€ React์—์„œ Form ๊ด€๋ฆฌ๋ฅผ ๊ฐ„ํŽธํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค. React Hooks๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค. useForm์„ ์‚ฌ์šฉํ•˜๋ฉด ์ƒํƒœ ๊ด€๋ฆฌ์™€ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋“ฑ์˜ ๋ณต์žกํ•œ ํผ ๊ด€๋ จ ์ž‘์—…์„ ๊ฐ„์†Œํ™”ํ•  ์ˆ˜ ์žˆ์–ด ๊ฐœ๋ฐœ์ž๋“ค์ด ํผ์„ ๋” ๋น ๋ฅด๊ณ  ์‰ฝ๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๊ฐœ๋ฐœ ์ƒ์‚ฐ์„ฑ์„ ๋†’์ด๊ณ  ์ฝ”๋“œ์˜ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค. UseForm's functionForm ์ƒํƒœ ๊ด€๋ฆฌ : useForm ํ›…์„ ์‚ฌ์šฉํ•˜์—ฌ ํผ์˜ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ..

Framework/React 2024.02.29
๋ฐ˜์‘ํ˜•