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
- Host: GitHub
- URL: https://github.com/chinsun9/react-banner-maker
- Owner: chinsun9
- Created: 2020-10-13T08:49:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-21T00:06:07.000Z (over 5 years ago)
- Last Synced: 2025-01-30T08:43:07.332Z (over 1 year ago)
- Topics: banner-maker, clone-coding, react, typesafe-actions, typescript, useeffect
- Language: TypeScript
- Homepage: https://chinsun9.github.io/react-banner-maker/
- Size: 654 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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/)
[](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๋ฅผ ์ง์ ํด์ค์ผํ๋ค.
### ์ปฌ๋ฌํฝ์ปค ์ํ๊ฐ ๋ชป๋ฐ๊พธ๋ ๋ฌธ์