โ์๊ฒ๋ ๊ฒ๊ณผ ๋๋์
- forwardRef
- styled component๋ฅผ importํ ๋ ๋ด๊ฐ ํ ์ค์ - Circular dependency
- ์์๋ฅผ ๊ด๋ฆฌํ๋ค๋ ๊ฒ์ - const์ Object.freeze
- ๋๋ฌด๋ง๊ณ ์ฒ์๋ณด๋ ์ฝ๋๋ฅผ ์ง๊ณ ์ถ๋ค
- netlify์์ ๋ฐฐํฌํ๊ธฐ (treat warning as errors) - CI=false npm run build
๐ฅ๊ทธ๋์ ํด๋ณด๋ ์ ๋ฆฌ
1. forwardRef
ํ์ ์ปดํฌ๋ํธ์ ์๋ ์๋ฆฌ๋จผํธ์ ์ ๊ทผํ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ค.
์ด๋ฒ์ ํ์๊ฐ์ ์ ๊ตฌํํ๋ฉด์, ์ ๋๋ก ์ ๋ ฅ ๋์ง ์์ ๊ฒฝ์ฐ์ toast๋ฅผ ๋์ฐ๋ฉด์ ํด๋น input์ focus๋ฅผ ์ฃผ๋ ์์ ์ ํ๋๋ฐ, ์ฃผ์ ์ ๋ ฅํ๋ ์นธ์ด ์ปดํฌ๋ํธ๋ก ๋ค์ด์์์ด์... focus๋ฅผ ์ด๋ป๊ฒ ์ฃผ์ฃ ? ~๊ณ ๋ฏผ์ ์์~
(1) ์์ ์ปดํฌ๋ํธ์์ Address๋ฅผ ์ธ ๋ ref๋ฅผ ๋๊ฒจ์ค๋ค
(2) ํ์ ์ปดํฌ๋ํธ์์ forwardRef๋ฅผ importํ๊ณ , ref๋ฅผ prop์ผ๋ก ๋ฐ์์จ๋ค
(3) ๊ทธ๋ฆฌ๊ณ ์์์ปดํฌ๋ํธ์์ ์กฐ์ํ๊ณ ์ถ์ ๋ถ๋ถ์ ref๋ฅผ ์ฃผ๊ณ ,
๋งจ ๋ฐ์ค์ export ํ ๋ export default forwardRef(์ปดํฌ๋ํธ๋ช ) ์ผ๋ก ์ ์ด์ค๋ค!
์๋๋ฉด const Address = forwardRef( (props, ref) => {... ์ด๋ฐ ์์ผ๋ก ์์์ ๊ฐ์ธ์ค๋ ๋๋ค.
2. styled component๋ฅผ importํ ๋ ๋ด๊ฐ ํ ์ค์
A์์ ์์ฑ๋ ์คํ์ผ๋ ์ปดํฌ๋ํธ๋ฅผ B์์ importํ๋ค
B์์ ๊ทธ๊ฑธ ์กฐ๊ธ ๋ณ๊ฒฝํด์ export ํด์ C์์ ๋ถ๋ฅด๋ ค ํ๋ค → ์ค๋ฅ๊ฐ ๋จ!
์ ์๋๋๊ฑธ๊น ํ์์์ฐธ ๊ณ ๋ฏผํ๋ค๊ฐ ํ์๋ถ๊ป ์ฌ์ญค๋ดค๋๋ ์๋ฌด๋๋ Circular dependency ์ค๋ฅ์ธ ๊ฒ ๊ฐ๋ค๊ณ ํ์ จ๋ค...
์๋๋๊ตฌ๋... ๋ญ๊ฐ ๋ ๊ฒ ๊ฐ์๋๋ฐ(ใ ใ ) ๊ฒ์ํด๋ณด๋ ์ ๋ ๊ฒ import ํ๋๊ฒ ์ข์ ๋ฐฉ๋ฒ์ด ์๋๋ผ๊ณ ํ๋ค์..
์๋ฌดํผ ๊ทธ๋์ A → B, A → C๋ก ๋ฐ๋ก import๋ฅผ ํด์ ์ด์ ๋ ์ ์๋ํ๋ค๊ณ ํฉ๋๋ค..
3. ์์๋ฅผ ๊ด๋ฆฌํ๋ค๋ ๊ฒ์
Object.freeze๋ ๊ฐ์ฒด๋ฅผ ๋ณ๊ฒฝํ์ง ๋ชปํ๋๋ก ํ๋ ๋ฐฉ๋ฒ์ด๋ค.
์ง๊ธ๊น์ง๋(๋ญ ์ค๋๋๊ฒ๋ ์๋์ง๋ง) const๋ฐ์ ๋ชฐ๋๋๋ฐ, const์์ ์ฐจ์ด์ ์
o1 = o2๋ฅผ ํ๋ฉด o1์ด ๊ฐ๋ฆฌํค๋ ๊ฐ์ด o2๊ฐ ๊ฐ๋ฆฌํค๋ ๊ฐ์ด ๋๋๋ฐ, const๋ ๊ทธ๊ฑธ ๋ฐฉ์งํด์ค๋ค.
๊ทผ๋ฐ ๋ง์ฝ o1.name='lee' ๋ผ๊ณ ๊ฐ์ ๋ฐ๊พธ๋ ค๊ณ ํ๋ฉด, ๊ทธ๊ฑธ ๋ง์์ฃผ๋๊ฑด freeze์ด๋ค.
์์ฝ : const๋ ๋ค๋ฅธ ๊ฐ์ ๋ชป ๊ฐ๋ฆฌํค๊ฒ ํจ, freeze๋ ๋ด์ฉ๋ฌผ ์์ฒด๋ฅผ ๋ชป ๋ฐ๊พธ๊ฒ ํจ
2๊ฐ ๋ค ์ฐ๋ฉด ์์ ํผํผํ๊ฒ ์งํค๋ ๊ฑฐ๊ฒ ๋ค์ฉ
4. ๋๋ฌด๋ง๊ณ ์ฒ์๋ณด๋ ์ฝ๋๋ฅผ ์ง๊ณ ์ถ๋ค
4-1. ์ด๋ฉ์ผ ์ค๋ณต ๊ฒ์ฌ๋ฅผ ์ง๋ฉด์
์ด๋ฉ์ผ ์ค๋ณต ๊ฒ์ฌ๋ฅผ ํ๊ณ , ์ค๋ณต๋ ์ด๋ฉ์ผ์ ๋๋ค! ๋ผ๊ณ toast๋ฅผ ๋์ ๋ค.
๊ทผ๋ฐ ํ ์คํธ๋ง ๋์ธ๊ฒ ์๋๋ผ ์์ ๊ฐ์ด ์ ์ฅ์ด ์๋๋๋ก ๋ง์๋๋ผ๋ฉด? ํจ์ฌ ์ข์ ์ฝ๋๊ฐ ๋์ ๊ฑฐ๋ผ๊ณ ์๊ฐํ๋ค...
ํ์๋๊ป์ ์ค๋ณต๊ฒ์ฌํ๋ ํจ์ ์์ flag ๊ฐ์ ์์ฑํด์ ํต๊ณผํ๋ฉด true๋ฅผ ๋ฆฌํดํ๋๋ก ์์ ํด์ฃผ์ จ๊ณ , ๊ทธ ํ๋๊ทธ๋ submit์ด ๋๋ ธ์ ๋ ๋ชจ๋ ๊ฐ์ ๊ฒ์ฌํ๋ ํจ์์์ ๋ถ๋ ค์ ์ ์ฉํ๊ฒ ์ฐ์๋ค. ์ค๋ณต์ ๊ฒ์ฌํด์ผ์ง! ํด์ ์ง์ง ์ค๋ณต๋ง ๊ฒ์ฌํ๋๊ฒ ์๋๋ผ.... ๊ทธ ๊ฐ์ด ์ด๋ป๊ฒ ํ๋ฌ๊ฐ๋์ง ์ชผ๋๋ง ๋ ์๊ฐํด์ ๋ด๋ค๋ณด๋ ์ฝ๋ฉ์ ํ์...๐ญ ์ฐ๋์ค
4-2. ์ ์ฒด์ ์ผ๋ก ํต์ผ๊ฐ ์๋ ์ฝ๋
์ด๊ฑด ๊ฐ์ธ์ (ํน์ ํ์) ์ทจํฅ์ผ ๊ฒ ๊ฐ๊ธฐ๋ ํ์ง๋ง... ๊ทธ๋ ์ง๋ง... ์ฝ๋๋ฅผ ๋ณผ ๋ ์ ์ฒด์ ์ธ ๋๋์ด ์ผ์ ํด ๋ณด์ด๋ ๊ฒ ์ข์ผ๋๊น์๐ฅบ ํ๋ฆฌ์จ๋ณด๋ฉ ํ๋ฉด์ ์ ๋ง ์ข์์ ์ด ๋๋ณด๋ค ์ํ๋ ์ฌ๋๋ค์ ์ฝ๋๋ฅผ ๋ค์ํ๊ฒ ๋ง์ด ๋ณผ ์ ์๋ค๋ ๊ฒ ๊ฐ๋ค!
๊ฐ์ ๊ธฐ๋ฅ์ ํ๋ ์ฝ๋๋ผ๋ ํ์์ ์ฃผ๋ณ ์ฝ๋์(??) ๋น์ทํ๊ฒ ์ง๋ฉด ๋์ค์ ๋ค์ ๋ณผ ๋ ์๋๋ฉด ๋ค๋ฅธ ์ฌ๋์ด ๋ณผ ๋ ์ข ๋ซ์ง์์๊น ํ๋ ์๊ฐ!!
5. netlify์์ ๋ฐฐํฌํ๊ธฐ (treat warning as errors)
However, one concern is that some libraries may now interpret what were previously just warnings as hard errors that will halt a build. The intention is that developers should not ship potentially broken configurations, but the downside is that builds that successfully completed previously may fail after this change. If you believe that your build is breaking after this change, you can disable this behavior by unsetting the CI variable in your build.
2020๋ ์... ์ด๋ฐ ์ ๋ฐ์ดํธ๋ฅผ ํ๋ค๊ณ ํ๋ค.... (์ถ์ฒ : ์ฌ๊ธฐ)
CI=false npm run build ๋๋ CI= npm run build ๋ก build๋ฅผ ํ๋ฉด warning์ error๋ก ์ทจ๊ธํ์ง ์๊ณ ์ ์์ผ๋ก ๋น๋๊ฐ ๋๋ค!
๐๊ณผ์ ํ๊ธฐ
7๋ช ์ด ํ๋ ๊ณผ์ ! ๊ทผ๋ฐ ์ ๋ง ๋ค๋ค ๋๋ฌด๋๋ฌด ์ ๊ทน์ ์ผ๋ก ์ฐธ์ฌํด์ฃผ์ ์ ํ๊ต๋ค๋๋ฉด์ ๊ฒช์๋ ๋ถ๋ ธ์ ํํ๋ค(^^)์ด ์น ์ํ์ง๋ ๊ธฐ๋ถ์ด์๋ค ๊ทธ๋ฆฌ๊ณ ๋ด๊ฐ 1์ธ๋ถ์ ํ๋๊ฐ์ ๋ํ ํฐ ์๋ฌธ์ด ๋ค์๋ค........
ํ๊ณ ์ถ์ ๋ถ๋ถ์ ๋๋ ๋, ๋ชป ํด๋ด๋ฉด ์ด๋กํ์ง ํ๋ ์๊ฐ์ด๋ ์๊ฒฌ์ ๋ด๋๊ฑฐ์ ๋ํ ๋๋ ค์?์ด ์ซ ์์๋๋ฐ,,,,, ์ด๋ฒ์ ํ์ ์ฐฝ ์ฐ๋๊ฑฐ๋ฅผ ๊ณต๋ถํ๊ณ ์ถ์ด์ ํ์๊ฐ์ ์ ํ๊ฒ ๋ค๊ณ ํ์๋ค. ๊ทธ๋ฆฌ๊ณ ์๊ฐ๋ณด๋ค ์ค๋๊ฑธ๋ ธ๋ค(ใ ใ ) ๊ทธ๋๋.... ์ผ๋จ ์์ฑ์ ๋์ผ๋ ๋คํ์ด๋ผ๊ณ ํด์ผํ ์ง...?
๊ทธ๋ฆฌ๊ณ ์ฌ์ค ์ ์ ์์ผ๋ก ํตํ๋ ๋ํํ๋๊ฑฐ๋ณด๋ค ํ ์คํธ๋ฅผ ์ ํธํ๋ ํธ์ธ๋ฐ, ๋งค์ผ ๋ชจ์ฌ์ ์คํฌ๋ผ ํ๋ค๋ณด๋ ์ต์ํด์ก๋ค!! ์ฐ๋ฆฌ์กฐ ์ฌ๋๋ค ๋ค๋ค ๋ ์ฐฉํด... ์ฒ์ฌ๋ผ๊ณ ... ๊ทธ์ ์ง์ฌ๋์ค
๋ฒ์จ 2์ฃผ๊ฐ ์ง๋๊ฐ๋ค ์๊ฐ ๋๋ฌด ์๊ฐ๋ค.. 8์ฃผ๊ฐ ์ง๋๊ณ ์ด๊ฑธ ๋ค ๋๋์ ๋๋ ๋๋ ์ด๋๊ฐ์ ์ ๋ ๋ฆฌ์กํธ ์ซ ๋ฐฐ์์งใ ํ๊ณ ๋งํ ์ ์์ ์ ๋๊ฐ ๋ผ์์ผ๋ฉด ์ข๊ฒ ๋ค๐ญ
๐์ฐธ๊ณ (โก)
Circular dependency for extracted styles with styled-components
I’m fairly new to styled-components and trying to extract / refactor styles to separate files. I have problem with circular dependency - probably because of lacks of experience in styled-components...
stackoverflow.com
https://opentutorials.org/module/4075/24884
๊ฐ์ฒด๋ฅผ ๋ถ๋ณํ๊ฒ ๋ง๋ค๊ธฐ (Object.freeze) - JavaScript Immutability
์์ ์๊ฐ ๊ฐ์ฒด๋ฅผ ๋ณ๊ฒฝํ์ง ๋ชปํ๋๋ก ํ๋ ๋ฐฉ๋ฒ์ธ Object.freeze๋ฅผ ์๊ฐํฉ๋๋ค. ๊ฐ์1 ์ฝ๋ var o1 = {name:'kim', score:[1,2]} Object.freeze(o1); Object.freeze(o1.score); o1.name = 'lee'; o1.city = 'seoul'; o1.score.push(3); consol
opentutorials.org
How to prevent Netlify from treating warnings as errors because process.env.CI = true?
Deploying new projects started failing on Netlify. Checking the logs I see something that was not in the logs on previous successful deploys: Treating warnings as errors because process.env.CI = t...
stackoverflow.com
Netlify not building - Command failed with exit code 1: npm run build
Hey, I can’t figure out why my app wont build on netlify. I tried building it locally it works, was checking for same file names, lowercase names that are different, tried removing json files and do a clean npm install, none helped. And it’s something
answers.netlify.com
'๐๊ณต๋ถ > ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 4์ฃผ์ฐจ - ๊ณผ์ 6 (0) | 2021.08.18 |
---|---|
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 3์ฃผ์ฐจ - ๊ณผ์ 4 (0) | 2021.08.11 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 2์ฃผ์ฐจ -๊ณผ์ 3(1) (0) | 2021.08.04 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 1์ฃผ์ฐจ -๊ณผ์ 2 (0) | 2021.08.01 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 1์ฃผ์ฐจ -๊ณผ์ 1 (0) | 2021.07.28 |
๋๊ธ