An open API service indexing awesome lists of open source software.

https://github.com/chinsun9/react-banner-maker

๐ŸŽจ banner maker clone
https://github.com/chinsun9/react-banner-maker

banner-maker clone-coding react typesafe-actions typescript useeffect

Last synced: about 1 year ago
JSON representation

๐ŸŽจ banner maker clone

Awesome Lists containing this project

README

          

# react-banner-maker

- [Banner Maker](https://banner.godori.dev/)์„ ๋ณด๊ณ  ๋งŒ๋“ค์–ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.
- html๋กœ๋งŒ ๋งŒ๋“  [html-banner-maker](https://github.com/chinsun9/html-banner-maker)๋ฅผ ๋ฆฌ์•กํŠธ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋‹ค์‹œ ๋งŒ๋“ค์–ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

## [๋ฐ๋ชจ](https://chinsun9.github.io/react-banner-maker/)

[![๋ฐ๋ชจ](readmeRes/preview.jpg)](https://chinsun9.github.io/react-banner-maker/)

## ๊ธฐ๋Šฅ

- ์บ”๋ฒ„์Šค ํฌ๊ธฐ ์กฐ์ ˆ
- ์‹ค์‹œ๊ฐ„ ์บ”๋ฒ„์Šค ์—…๋ฐ์ดํŠธ
- ํฐํŠธ ์‚ฌ์ด์ฆˆ ์กฐ์ ˆ
- ํฐํŠธ์ƒ‰ ์กฐ์ ˆ
- ์บ”๋ฒ„์Šค์ƒ‰์— ๋”ฐ๋ฅธ ํฐํŠธ์ƒ‰ ์ž๋™์กฐ์ ˆ
- ์บ”๋ฒ„์Šค์ƒ‰ ์กฐ์ ˆ
- ๋žœ๋ค ์บ ๋ฒ„์Šค์ƒ‰
- ์ด๋ฏธ์ง€๋กœ ๋‹ค์šด๋กœ๋“œ
- ํด๋ฆฝ๋ณด๋“œ๋กœ ์นดํ”ผ
- ์ปฌ๋Ÿฌ ํžˆ์Šคํ† ๋ฆฌ ๊ธฐ๋Šฅ
- ์ปฌ๋Ÿฌ ํžˆ์Šคํ† ๋ฆฌ ์ž„ํฌํŠธ, ์ต์ŠคํฌํŠธ ๊ธฐ๋Šฅ




## create-react-app์œผ๋กœ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

```
npx create-react-app . --typescript
yarn add redux react-redux @types/react-redux
```

## yarn add typesafe-actions

```cmd cmd
yarn add typesafe-actions
```

- typesafe-actions ์„ค์น˜ํ•ด์„œ ์•ก์…˜๊ณผ ๋ฆฌ๋“€์„œ ํŽธํ•˜๊ฒŒ ๋งŒ๋“ค๊ธฐ

## ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ๊ฒช์€ ๋ฌธ์ œ๋“ค..

### parsing error: cannot read property 'name' of undefined

```ts modules/history/index.ts
export { default } from './reducer';
export * from './actions';
export * from './types';
```

- ํŒŒ์ผ ๋ถ„๋ฆฌ๋ฅผํ•  ๋•Œ ์œ„ ๋ฌธ๋ฒ•์—์„œ lint ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.
- ๊ธฐ์กด `yarn.lock`ํŒŒ์ผ์„ ์‚ญ์ œํ•œ๋‹ค.

```json package.json
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0"
},
```

- ๋…ธ๋“œ๋ชจ๋“ˆ ํด๋”๋ฅผ ์‚ญ์ œํ•œ๋‹ค
- `npm i`๋กœ ๋‹ค์‹œ ๋…ธ๋“œ๋ชจ๋“ˆ์„ ์„ค์น˜ํ•œ๋‹ค.

- ๋‚˜๋Š” ts๋ฒ„์ „์ด 3.7์ด์˜€๋Š”๋ฐ, ์ด ๊ฒฝ์šฐ eslint๋ฅผ 2.23์œผ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๋ผ๊ณ  ํ•œ๋‹ค.
- https://github.com/typescript-eslint/typescript-eslint/issues/1746
- https://stackoverflow.com/questions/60729199/react-typescript-line-0-parsing-error-cannot-read-property-name-of-undefine

### useEffect ์‚ฌ์šฉํ•ด์„œ Canvas ์ดˆ๊ธฐํ™” ๋ฐ ์—…๋ฐ์ดํŠธ ํ•˜๊ธฐ

- useEffect๋ฅผ ์‚ฌ์šฉ์•ˆํ•˜๋‹ˆ๊นŒ ์ฒ˜์Œ ์›น์„ ๋กœ๋”ฉํ–ˆ์„๋•Œ ์บ”๋ฒ„์Šค ์ดˆ๊ธฐํ™”๋ฅผ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—‡๋‹ค.

### Type 'boolean' is not assignable to type 'never'.ts(2322)

```ts Canvas.tsx
const offsets = lines
.map((_line, index) => index)
.reduce((prev, curr) => {
const subtract = curr - mid;
prev.push([subtract < 0, parseInt(subtract.toString(), 10)]);
return prev;
}, new Array<[boolean, number]>());
```
- prev.push ํ•˜๋Š” ํƒ€์ž…์— ๋งž๊ฒŒ ๋ฐฐ์—ด์„ ์„ ์–ธํ•ด ๋„ฃ์–ด์ค˜์•ผํ•œ๋‹ค.

### react Object is possibly 'null'. useref

```ts Canvas.tsx
const canvas = canvasRef.current;

const canvas = (canvasRef as any).current;
```

- ์œ„์ฒ˜๋Ÿผ ํ•˜๋‹ˆ๊นŒ ์•ˆ๋ฌ๋Š”๋ฐ, ์•„๋ž˜์ฒ˜๋Ÿผ ํ•˜๋‹ˆ๊นŒ ๋ฌ๋‹ค.

### reactcss Type '{ position: string; zIndex: string; }' is not assignable to type 'CSSProperties'. Types of property 'position' are incompatible.

```tsx SettingCanvasDetail.tsx
popover: {
position: 'absolute',
zIndex: 3 ,
} as CSSProperties,
```

- ` as CSSProperties`๋ฅผ ๋ถ™์—ฌ์ฃผ๋‹ˆ๊นŒ ์ž˜ ์ ์šฉ๋˜์—ˆ๋‹ค.
- ๋˜ zIndex์˜ ๊ฐ’์€ number๋กœ ์ค˜์•ผํ•œ๋‹ค.

### ๋ฆฌ์•กํŠธ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ์—์„œ ํ”„๋ฆฌํ‹ฐ์–ด ์ ์šฉํ•˜๊ธฐ
```json settings.json
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
```
- ์ €์žฅํ• ๋•Œ ์ž๋™์œผ๋กœ ํฌ๋งทํŒ…ํ• ๋ ค๋ฉด formatOnSave, defaultFormatter๋ฅผ ์ง€์ •ํ•ด์ค˜์•ผํ•œ๋‹ค.

### ์ปฌ๋Ÿฌํ”ฝ์ปค ์•ŒํŒŒ๊ฐ’ ๋ชป๋ฐ”๊พธ๋Š” ๋ฌธ์ œ